Update Investbrain installation script and improve backup management

This commit is contained in:
Benito Rodríguez 2026-01-05 17:20:25 +01:00
parent 8c5b7b4ade
commit 61b0ecf702
3 changed files with 59 additions and 120 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG # Copyright (c) 2021-2025 community-scripts ORG
# Author: Benito Rodríguez (b3ni) # Author: Benito Rodríguez (b3ni)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@ -29,56 +29,44 @@ function update_script() {
exit exit
fi fi
PG_VERSION="17" setup_postgresql
if check_for_gh_release "Investbrain" "investbrainapp/investbrain"; then if check_for_gh_release "Investbrain" "investbrainapp/investbrain"; then
msg_info "Stopping Services" msg_info "Stopping Services"
systemctl stop nginx systemctl stop nginx php8.4-fpm
systemctl stop php8.4-fpm
supervisorctl stop all supervisorctl stop all
msg_ok "Services Stopped" msg_ok "Services Stopped"
PHP_VERSION="8.4" PHP_FPM=YES PHP_MODULE="gd,zip,intl,pdo,pgsql,pdo-pgsql,bcmath,opcache,mbstring,redis" setup_php
setup_composer
NODE_VERSION="22" setup_nodejs
PG_VERSION="17" setup_postgresql
msg_info "Creating Backup" msg_info "Creating Backup"
rm -f /opt/.env.backup rm -f /opt/.env.backup
rm -rf /opt/storage.backup rm -rf /opt/investbrain_backup
cp /opt/investbrain/.env /opt/.env.backup cp /opt/investbrain/.env /opt/.env.backup
cp -r /opt/investbrain/storage /opt/storage.backup cp -r /opt/investbrain/storage /opt/investbrain_backup
msg_ok "Created Backup" msg_ok "Created Backup"
msg_info "Updating Investbrain"
rm -rf /opt/investbrain-new rm -rf /opt/investbrain-new
mkdir -p /opt/investbrain-new mkdir -p /opt/investbrain-new
fetch_and_deploy_gh_release "Investbrain" "investbrainapp/investbrain" "tarball" "latest" "/opt/investbrain-new" fetch_and_deploy_gh_release "Investbrain" "investbrainapp/investbrain" "tarball" "latest" "/opt/investbrain-new"
msg_info "Updating Investbrain"
cd /opt/investbrain cd /opt/investbrain
cp -r /opt/investbrain-new/* /opt/investbrain/ cp -r /opt/investbrain-new/* /opt/investbrain/
rm -rf /opt/investbrain/storage rm -rf /opt/investbrain/storage
rm -rf /opt/investbrain-new rm -rf /opt/investbrain-new
cp /opt/.env.backup /opt/investbrain/.env cp /opt/.env.backup /opt/investbrain/.env
cp -r /opt/storage.backup/ /opt/investbrain/storage cp -r /opt/investbrain_backup/ /opt/investbrain/storage
mkdir -p /opt/investbrain/storage/{framework/cache,framework/sessions,framework/views,app,logs}
chown -R www-data:www-data /opt/investbrain
chmod -R 775 /opt/investbrain/storage
mkdir -p /opt/investbrain/storage/framework/cache/data
mkdir -p /opt/investbrain/storage/framework/sessions
mkdir -p /opt/investbrain/storage/framework/views
mkdir -p /opt/investbrain/storage/logs
mkdir -p /opt/investbrain/bootstrap/cache
chown -R www-data:www-data /opt/investbrain/{storage,bootstrap/cache}
PHP_VERSION="8.4" PHP_FPM=YES PHP_MODULE="gd,zip,intl,pdo,pgsql,pdo-pgsql,bcmath,opcache,mbstring,redis" setup_php
setup_composer
export COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --no-interaction --no-dev --optimize-autoloader $STD composer install --no-interaction --no-dev --optimize-autoloader
$STD npm install $STD npm install
$STD npm run build $STD npm run build
$STD php artisan storage:link $STD php artisan storage:link
$STD php artisan migrate --force $STD php artisan migrate --force
$STD php artisan cache:clear $STD php artisan cache:clear
$STD php artisan view:clear $STD php artisan view:clear
$STD php artisan route:clear $STD php artisan route:clear
@ -87,20 +75,17 @@ function update_script() {
$STD php artisan event:cache $STD php artisan event:cache
chown -R www-data:www-data /opt/investbrain chown -R www-data:www-data /opt/investbrain
chmod -R 755 /opt/investbrain/storage /opt/investbrain/bootstrap/cache chmod -R 775 /opt/investbrain/storage /opt/investbrain/bootstrap/cache
rm -rf /opt/.env.backup /opt/storage.backup rm -rf /opt/.env.backup /opt/investbrain_backup
msg_ok "Updated Investbrain" msg_ok "Updated Investbrain"
msg_info "Starting Services" msg_info "Starting Services"
systemctl start php8.4-fpm systemctl start php8.4-fpm nginx
systemctl start nginx
supervisorctl start all supervisorctl start all
msg_ok "Services Started" msg_ok "Services Started"
msg_ok "Updated Successfully!" msg_ok "Updated Successfully!"
else
msg_ok "No update available"
fi fi
exit exit
} }

View File

@ -1,7 +1,9 @@
{ {
"name": "Investbrain", "name": "Investbrain",
"slug": "investbrain", "slug": "investbrain",
"categories": [23], "categories": [
23
],
"date_created": "2025-12-26", "date_created": "2025-12-26",
"type": "ct", "type": "ct",
"updateable": true, "updateable": true,
@ -9,7 +11,7 @@
"interface_port": 8000, "interface_port": 8000,
"documentation": "https://github.com/investbrainapp/investbrain", "documentation": "https://github.com/investbrainapp/investbrain",
"website": "https://investbra.in", "website": "https://investbra.in",
"logo": "https://raw.githubusercontent.com/investbrainapp/investbrain/main/investbrain-logo.png", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/investbrain.webp",
"config_path": "/opt/investbrain/.env", "config_path": "/opt/investbrain/.env",
"description": "Investbrain is a smart open-source investment tracker that helps you manage, track, and make informed decisions about your investments.", "description": "Investbrain is a smart open-source investment tracker that helps you manage, track, and make informed decisions about your investments.",
"install_methods": [ "install_methods": [
@ -30,26 +32,6 @@
"password": null "password": null
}, },
"notes": [ "notes": [
{
"text": "Access the UI via http://<host-ip>:8000/register to create the first user.",
"type": "info"
},
{
"text": "Default market data provider is Yahoo Finance. Configure others in `.env` with `MARKET_DATA_PROVIDER=yahoo,alphavantage`",
"type": "info"
},
{
"text": "Refresh market data: `cd /opt/investbrain && php artisan refresh:market-data`",
"type": "info"
},
{
"text": "Enable AI chat by setting `AI_CHAT_ENABLED=true` and `OPENAI_API_KEY` in `.env`",
"type": "info"
},
{
"text": "View logs: `ls /opt/investbrain/storage/logs/` (daily rotation: laravel-YYYY-MM-DD.log)",
"type": "info"
},
{ {
"text": "Database credentials: `cat ~/investbrain.creds`", "text": "Database credentials: `cat ~/investbrain.creds`",
"type": "info" "type": "info"

View File

@ -33,12 +33,13 @@ NODE_VERSION="22" setup_nodejs
PG_VERSION="17" setup_postgresql PG_VERSION="17" setup_postgresql
PG_DB_NAME="investbrain" PG_DB_USER="investbrain" setup_postgresql_db PG_DB_NAME="investbrain" PG_DB_USER="investbrain" setup_postgresql_db
msg_info "Installing Investbrain"
mkdir -p /opt/investbrain mkdir -p /opt/investbrain
fetch_and_deploy_gh_release "Investbrain" "investbrainapp/investbrain" "tarball" "latest" "/opt/investbrain" fetch_and_deploy_gh_release "Investbrain" "investbrainapp/investbrain" "tarball" "latest" "/opt/investbrain"
LOCAL_IP=$(hostname -I | awk '{print $1}') LOCAL_IP=$(hostname -I | awk '{print $1}')
APP_KEY=$(openssl rand -base64 32) APP_KEY=$(openssl rand -base64 32)
msg_info "Installing Investbrain (Patience)"
cd /opt/investbrain
cat <<EOF >/opt/investbrain/.env cat <<EOF >/opt/investbrain/.env
APP_KEY=base64:${APP_KEY} APP_KEY=base64:${APP_KEY}
APP_PORT=8000 APP_PORT=8000
@ -91,43 +92,24 @@ MAIL_FROM_ADDRESS="investbrain@${LOCAL_IP}"
VITE_APP_NAME=Investbrain VITE_APP_NAME=Investbrain
EOF EOF
msg_ok "Setup Investbrain"
msg_info "Installing Investbrain (Patience)"
export COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --no-interaction --no-dev --optimize-autoloader $STD composer install --no-interaction --no-dev --optimize-autoloader
$STD npm install $STD npm install
$STD npm run build $STD npm run build
msg_ok "Installed Investbrain" mkdir -p /opt/investbrain/storage/{framework/cache,framework/sessions,framework/views,app,logs}
msg_info "Setting up Storage"
mkdir -p /opt/investbrain/storage/framework/cache
mkdir -p /opt/investbrain/storage/framework/sessions
mkdir -p /opt/investbrain/storage/framework/views
mkdir -p /opt/investbrain/storage/app
mkdir -p /opt/investbrain/storage/logs
chmod -R 775 /opt/investbrain/storage
chown -R www-data:www-data /opt/investbrain/storage
msg_ok "Setup Storage"
msg_info "Running Migrations"
$STD php artisan migrate --force $STD php artisan migrate --force
$STD php artisan storage:link $STD php artisan storage:link
msg_ok "Ran Migrations"
msg_info "Clearing and Caching"
$STD php artisan cache:clear $STD php artisan cache:clear
$STD php artisan view:clear $STD php artisan view:clear
$STD php artisan route:clear $STD php artisan route:clear
$STD php artisan event:clear $STD php artisan event:clear
$STD php artisan route:cache $STD php artisan route:cache
$STD php artisan event:cache
chown -R www-data:www-data /opt/investbrain chown -R www-data:www-data /opt/investbrain
chmod -R 755 /opt/investbrain/bootstrap/cache chmod -R 775 /opt/investbrain/bootstrap/cache
msg_ok "Cleared and Cached" msg_ok "Installed Investbrain"
msg_info "Configuring Nginx" msg_info "Configuring Nginx"
PHPVER=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "\n";')
cat <<EOF >/etc/nginx/sites-available/investbrain.conf cat <<EOF >/etc/nginx/sites-available/investbrain.conf
server { server {
listen 8000 default_server; listen 8000 default_server;
@ -148,7 +130,7 @@ server {
} }
location ~ \.php\$ { location ~ \.php\$ {
fastcgi_pass unix:/var/run/php/php${PHPVER}-fpm.sock; fastcgi_pass unix:/var/run/php/php${PHP_VERSION}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
fastcgi_hide_header X-Powered-By; fastcgi_hide_header X-Powered-By;
@ -163,7 +145,6 @@ server {
access_log /var/log/nginx/investbrain_access.log; access_log /var/log/nginx/investbrain_access.log;
} }
EOF EOF
ln -sf /etc/nginx/sites-available/investbrain.conf /etc/nginx/sites-enabled/ ln -sf /etc/nginx/sites-available/investbrain.conf /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default rm -f /etc/nginx/sites-enabled/default
$STD systemctl reload nginx $STD systemctl reload nginx
@ -183,7 +164,6 @@ stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10 stdout_logfile_backups=10
numprocs=1 numprocs=1
EOF EOF
$STD supervisorctl reread $STD supervisorctl reread
$STD supervisorctl update $STD supervisorctl update
$STD supervisorctl start all $STD supervisorctl start all
@ -197,14 +177,6 @@ chmod 644 /etc/cron.d/investbrain-scheduler
$STD systemctl restart cron $STD systemctl restart cron
msg_ok "Setup Cron for Scheduler" msg_ok "Setup Cron for Scheduler"
{
echo ""
echo "Investbrain Database Credentials"
echo "Database Name: ${PG_DB_NAME}"
echo "Database User: ${PG_DB_USER}"
echo "Database Password: ${PG_DB_PASS}"
} >>~/investbrain.creds
motd_ssh motd_ssh
customize customize
cleanup_lxc cleanup_lxc