Files
HomeServerCTs/CT-Files/linkwarden/Scripts/FirstRun.sh
2025-01-05 22:33:27 +01:00

31 lines
945 B
Bash

#!/bin/bash
ThisScriptConfigured=no
##Linkwarden
LinkwardenURL=http://localhost:3000
##DB
PostgresqlIP=127.0.0.1
PostgresqlPort=5432
PostgresqlUsername=linkwarden
PostgresqlDatabase=linkwarden
PostgresqlPassword=<Password>
#Check if script is configured
if [ $ThisScriptConfigured = no ]; then
echo "Script is not configured"
exit
fi
##Update config
sed -i "s#^DATABASE_URL=#DATABASE_URL=postgresql://$PostgresqlUsername:$PostgresqlPassword@$PostgresqlIP:$PostgresqlPort/$PostgresqlDatabase#" /opt/node/linkwarden/.env
sed -i "s/NEXTAUTH_SECRET=/NEXTAUTH_SECRET=$(dd bs=32 count=1 if=/dev/urandom | base64 | tr +/ _.)/" /opt/node/linkwarden/.env
sed -i "s#http://localhost:3000#$LinkwardenURL#" /opt/node/linkwarden/.env
#Save PM2 statup config
sudo -u node bash << EOF
(cd /opt/node/linkwarden; yarn prisma migrate deploy)
pm2 install pm2-logrotate
pm2 start yarn --name Linkwarden --cwd /opt/node/linkwarden -- start
pm2 save
EOF