wip: add ghostfolio
This commit is contained in:
parent
0d1638e391
commit
f4be7b6f24
72
ct/ghostfolio.sh
Normal file
72
ct/ghostfolio.sh
Normal file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
# Author: lucasfell
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://ghostfol.io/
|
||||
|
||||
APP="Ghostfolio"
|
||||
var_tags="${var_tags:-finance;investment}"
|
||||
var_cpu="${var_cpu:-2}"
|
||||
var_ram="${var_ram:-2048}"
|
||||
var_disk="${var_disk:-8}"
|
||||
var_os="${var_os:-debian}"
|
||||
var_version="${var_version:-12}"
|
||||
var_unprivileged="${var_unprivileged:-1}"
|
||||
|
||||
header_info "$APP"
|
||||
variables
|
||||
color
|
||||
catch_errors
|
||||
|
||||
function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
|
||||
if [[ ! -f /opt/ghostfolio/dist/apps/api/main.js ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
msg_info "Stopping $APP"
|
||||
systemctl stop ghostfolio
|
||||
msg_ok "Stopped $APP"
|
||||
|
||||
msg_info "Creating Backup"
|
||||
tar -czf "/opt/ghostfolio_backup_$(date +%F).tar.gz" /opt/ghostfolio
|
||||
msg_ok "Backup Created"
|
||||
|
||||
msg_info "Updating $APP"
|
||||
cd /opt/ghostfolio
|
||||
git fetch --all
|
||||
RELEASE=$(git describe --tags --abbrev=0 origin/main)
|
||||
if [[ "${RELEASE}" != "$(cat /opt/ghostfolio_version.txt)" ]] || [[ ! -f /opt/ghostfolio_version.txt ]]; then
|
||||
git checkout ${RELEASE}
|
||||
npm ci
|
||||
npm run build:production
|
||||
npm run database:migrate
|
||||
echo "${RELEASE}" >/opt/ghostfolio_version.txt
|
||||
msg_ok "Updated $APP to ${RELEASE}"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||
fi
|
||||
|
||||
msg_info "Starting $APP"
|
||||
systemctl start ghostfolio
|
||||
msg_ok "Started $APP"
|
||||
|
||||
msg_info "Cleaning Up"
|
||||
npm cache clean --force
|
||||
msg_ok "Cleanup Completed"
|
||||
exit
|
||||
}
|
||||
|
||||
start
|
||||
build_container
|
||||
description
|
||||
|
||||
msg_ok "Completed Successfully!\n"
|
||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3333${CL}"
|
46
frontend/public/json/ghostfolio.json
Normal file
46
frontend/public/json/ghostfolio.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "Ghostfolio",
|
||||
"slug": "ghostfolio",
|
||||
"categories": [23],
|
||||
"date_created": "2025-08-14",
|
||||
"type": "ct",
|
||||
"updateable": true,
|
||||
"privileged": false,
|
||||
"interface_port": 3333,
|
||||
"documentation": "https://github.com/ghostfolio/ghostfolio?tab=readme-ov-file#self-hosting",
|
||||
"website": "https://ghostfol.io/",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/ghostfolio.webp",
|
||||
"config_path": "/opt/ghostfolio/.env",
|
||||
"description": "Ghostfolio is an open source wealth management software built with web technology. The application empowers busy people to keep track of stocks, ETFs or cryptocurrencies and make solid, data-driven investment decisions.",
|
||||
"install_methods": [
|
||||
{
|
||||
"type": "default",
|
||||
"script": "ct/ghostfolio.sh",
|
||||
"resources": {
|
||||
"cpu": 2,
|
||||
"ram": 2048,
|
||||
"hdd": 8,
|
||||
"os": "debian",
|
||||
"version": "12"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_credentials": {
|
||||
"username": null,
|
||||
"password": null
|
||||
},
|
||||
"notes": [
|
||||
{
|
||||
"text": "Create your first user account by visiting the web interface and clicking 'Get Started'. The first user will automatically get admin privileges.",
|
||||
"type": "info"
|
||||
},
|
||||
{
|
||||
"text": "Database and Redis credentials: `cat ~/ghostfolio.creds`",
|
||||
"type": "info"
|
||||
},
|
||||
{
|
||||
"text": "Configuration file: `/opt/ghostfolio/.env`",
|
||||
"type": "info"
|
||||
}
|
||||
]
|
||||
}
|
132
install/ghostfolio-install.sh
Normal file
132
install/ghostfolio-install.sh
Normal file
@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
# Author: lucasfell
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://ghostfol.io/
|
||||
|
||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||
color
|
||||
verb_ip6
|
||||
catch_errors
|
||||
setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt-get install -y \
|
||||
git \
|
||||
build-essential \
|
||||
python3 \
|
||||
openssl \
|
||||
curl \
|
||||
ca-certificates
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
PG_VERSION="15" setup_postgresql
|
||||
|
||||
msg_info "Installing Redis"
|
||||
$STD apt-get install -y redis-server
|
||||
systemctl enable -q --now redis-server
|
||||
msg_ok "Installed Redis"
|
||||
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
|
||||
msg_info "Setting up Database"
|
||||
DB_NAME=ghostfolio
|
||||
DB_USER=ghostfolio
|
||||
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||
REDIS_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||
ACCESS_TOKEN_SALT=$(openssl rand -base64 32)
|
||||
JWT_SECRET_KEY=$(openssl rand -base64 32)
|
||||
|
||||
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
|
||||
$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_PASS';"
|
||||
$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
|
||||
$STD sudo -u postgres psql -c "ALTER USER $DB_USER CREATEDB;"
|
||||
|
||||
{
|
||||
echo "Ghostfolio Credentials"
|
||||
echo "Database User: $DB_USER"
|
||||
echo "Database Password: $DB_PASS"
|
||||
echo "Database Name: $DB_NAME"
|
||||
echo "Redis Password: $REDIS_PASS"
|
||||
echo "Access Token Salt: $ACCESS_TOKEN_SALT"
|
||||
echo "JWT Secret Key: $JWT_SECRET_KEY"
|
||||
} >>~/ghostfolio.creds
|
||||
msg_ok "Set up Database"
|
||||
|
||||
msg_info "Configuring Redis"
|
||||
sed -i "s/# requirepass foobared/requirepass $REDIS_PASS/" /etc/redis/redis.conf
|
||||
systemctl restart redis-server
|
||||
msg_ok "Configured Redis"
|
||||
|
||||
msg_info "Cloning Ghostfolio"
|
||||
cd /opt
|
||||
$STD git clone https://github.com/ghostfolio/ghostfolio.git
|
||||
cd ghostfolio
|
||||
RELEASE=$(git describe --tags --abbrev=0)
|
||||
git checkout $RELEASE
|
||||
msg_ok "Cloned Ghostfolio $RELEASE"
|
||||
|
||||
msg_info "Installing Ghostfolio Dependencies"
|
||||
$STD npm ci
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Building Ghostfolio"
|
||||
$STD npm run build:production
|
||||
msg_ok "Built Ghostfolio"
|
||||
|
||||
msg_info "Setting up Environment"
|
||||
cat <<EOF >/opt/ghostfolio/.env
|
||||
DATABASE_URL=postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME?connect_timeout=300&sslmode=prefer
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=$REDIS_PASS
|
||||
ACCESS_TOKEN_SALT=$ACCESS_TOKEN_SALT
|
||||
JWT_SECRET_KEY=$JWT_SECRET_KEY
|
||||
NODE_ENV=production
|
||||
PORT=3333
|
||||
HOST=0.0.0.0
|
||||
EOF
|
||||
msg_ok "Set up Environment"
|
||||
|
||||
msg_info "Running Database Migrations"
|
||||
cd /opt/ghostfolio/dist/apps/api
|
||||
$STD npx prisma migrate deploy
|
||||
$STD npx prisma db seed
|
||||
msg_ok "Database Migrations Complete"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/ghostfolio.service
|
||||
[Unit]
|
||||
Description=Ghostfolio Investment Tracker
|
||||
After=network.target postgresql.service redis-server.service
|
||||
Wants=postgresql.service redis-server.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/ghostfolio/dist/apps/api
|
||||
Environment=NODE_ENV=production
|
||||
EnvironmentFile=/opt/ghostfolio/.env
|
||||
ExecStart=/usr/bin/node main.js
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl enable -q --now ghostfolio
|
||||
echo "$RELEASE" >/opt/ghostfolio_version.txt
|
||||
msg_ok "Created Service"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
||||
msg_info "Cleaning up"
|
||||
npm cache clean --force
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
msg_ok "Cleaned"
|
Loading…
x
Reference in New Issue
Block a user