Make this work more like my original script

This commit is contained in:
Jesse Antoszyk 2024-10-22 20:27:07 -04:00 committed by GitHub
parent e1c8be0f92
commit b114aa4012
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 11 deletions

View File

@ -114,8 +114,8 @@ $STD rm ghostfolio-$GHOSTFOLIO_VERSION.tgz
cd /opt/ghostfolio-$GHOSTFOLIO_VERSION cd /opt/ghostfolio-$GHOSTFOLIO_VERSION
# Stash these so we have clean versions later # Stash these so we have clean versions later
cp /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json.bak #cp /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json.bak
cp /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json.bak #cp /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json.bak
# Get node version and install node # Get node version and install node
test -f .nvmrc && NODE_VERSION=$(sed 's/^v\([0-9]*\)[.]*.*/\1/g' .nvmrc) # get first digits after an v, excluding potential .minor.patch versions test -f .nvmrc && NODE_VERSION=$(sed 's/^v\([0-9]*\)[.]*.*/\1/g' .nvmrc) # get first digits after an v, excluding potential .minor.patch versions
@ -130,15 +130,16 @@ $STD npm install
$STD npm run build:production $STD npm run build:production
# package.json was generated by the build process, however the original package-lock.json needs to be used to ensure the same versions # package.json was generated by the build process, however the original package-lock.json needs to be used to ensure the same versions
mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json.bak /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/package-lock.json # mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json.bak /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/package-lock.json
$STD curl -o package-lock.json https://raw.githubusercontent.com/ghostfolio/ghostfolio/refs/tags/$GHOSTFOLIO_VERSION/package-lock.json
cd /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/ cd /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/
$STD npm install $STD npm install
mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/prisma . cp -r /opt/ghostfolio-$GHOSTFOLIO_VERSION/prisma .
# Overwrite the generated package.json with the original one to ensure having all the scripts # Overwrite the generated package.json with the original one to ensure having all the scripts
mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json.bak /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/package.json # mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json.bak /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/package.json
$STD curl -o package.json https://raw.githubusercontent.com/ghostfolio/ghostfolio/refs/tags/$GHOSTFOLIO_VERSION/package.json
$STD npm run database:generate-typings $STD npm run database:generate-typings
# Move the built project to /opt/ghostfolio # Move the built project to /opt/ghostfolio
@ -159,10 +160,12 @@ cat <<EOF >/opt/ghostfolio/api/.env
REDIS_HOST=$REDIS_HOST REDIS_HOST=$REDIS_HOST
REDIS_PORT=$REDIS_PORT REDIS_PORT=$REDIS_PORT
REDIS_PASSWORD=$REDIS_PASSWORD REDIS_PASSWORD=$REDIS_PASSWORD
# POSTGRES # POSTGRES
POSTGRES_DB=$POSTGRES_DB POSTGRES_DB=$POSTGRES_DB
POSTGRES_USER=$POSTGRES_USER POSTGRES_USER=$POSTGRES_USER
POSTGRES_PASSWORD=$POSTGRES_PASSWORD POSTGRES_PASSWORD=$POSTGRES_PASSWORD
# VARIOUS # VARIOUS
ACCESS_TOKEN_SALT=$ACCESS_TOKEN_SALT ACCESS_TOKEN_SALT=$ACCESS_TOKEN_SALT
DATABASE_URL="$DATABASE_URL" DATABASE_URL="$DATABASE_URL"
@ -176,6 +179,7 @@ cat <<EOF >/opt/ghostfolio/start.sh
set -a set -a
. /opt/ghostfolio/api/.env . /opt/ghostfolio/api/.env
set +a set +a
# Run the docker entrypoint # Run the docker entrypoint
/opt/ghostfolio/entrypoint.sh /opt/ghostfolio/entrypoint.sh
EOF EOF
@ -187,19 +191,24 @@ msg_info "Creating Systemd Service Definition"
cat <<EOF >/etc/systemd/system/ghostfolio.service cat <<EOF >/etc/systemd/system/ghostfolio.service
[Unit] [Unit]
Description=ghostfolio Description=ghostfolio
[Service] [Service]
After=postgresql.service redis.service After=postgresql.service redis.service
Require=postgresql.service redis.service Require=postgresql.service redis.service
# Start Service # Start Service
ExecStart=/opt/ghostfolio/start.sh ExecStart=/opt/ghostfolio/start.sh
WorkingDirectory=/opt/ghostfolio/api/ WorkingDirectory=/opt/ghostfolio/api/
# Restart service after 10 seconds if node service crashes # Restart service after 10 seconds if node service crashes
RestartSec=10 RestartSec=10
Restart=always Restart=always
# Output to syslog # Output to syslog
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog
SyslogIdentifier=ghostfolio SyslogIdentifier=ghostfolio
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
@ -213,8 +222,8 @@ msg_ok "Created Startup Scripts"
motd_ssh motd_ssh
customize customize
msg_info "Cleaning up" # msg_info "Cleaning up"
apt remove -y make git g++ # apt remove -y make git g++
$STD apt-get -y autoremove # $STD apt-get -y autoremove
$STD apt-get -y autoclean # $STD apt-get -y autoclean
msg_ok "Cleaned" # msg_ok "Cleaned"