From 50e5c6982b76459d95a8318efba35618e66e179a Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 1 Oct 2026 08:12:33 +0200 Subject: [PATCH] Use setup_postgresql_db / setup_mariadb_db instead of hand-written SQL (#17622) Also append instead of overwrite the second creds block in onlyoffice, planka and pterodactyl-panel, which dropped the database credentials. --- install/glpi-install.sh | 22 ++++------------------ install/keycloak-install.sh | 13 +++---------- install/kimai-install.sh | 17 ++--------------- install/limesurvey-install.sh | 15 +-------------- install/listmonk-install.sh | 16 ++-------------- install/managemydamnlife-install.sh | 21 ++++----------------- install/mattermost-install.sh | 19 ++----------------- install/mediamanager-install.sh | 21 ++++----------------- install/odoo-install.sh | 21 +++------------------ install/onlyoffice-install.sh | 25 +++++-------------------- install/paymenter-install.sh | 22 ++++++---------------- install/planka-install.sh | 21 +++------------------ install/pterodactyl-panel-install.sh | 19 +++---------------- 13 files changed, 42 insertions(+), 210 deletions(-) diff --git a/install/glpi-install.sh b/install/glpi-install.sh index af508514a..4d25a5bc8 100644 --- a/install/glpi-install.sh +++ b/install/glpi-install.sh @@ -24,22 +24,8 @@ msg_ok "Installed Dependencies" setup_mariadb -msg_info "Setting up database" -DB_NAME=glpi_db -DB_USER=glpi -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) mariadb-tzinfo-to-sql /usr/share/zoneinfo | mariadb mysql -$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" -$STD mariadb -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';" -$STD mariadb -u root -e "GRANT SELECT ON \`mysql\`.\`time_zone_name\` TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" -cat <~/glpi_db.creds -GLPI Database Credentials -Database: $DB_NAME -Username: $DB_USER -Password: $DB_PASS -EOF -msg_ok "Set up database" +MARIADB_DB_NAME="glpi_db" MARIADB_DB_USER="glpi" MARIADB_DB_EXTRA_GRANTS="GRANT SELECT ON \`mysql\`.\`time_zone_name\`" MARIADB_DB_CREDS_FILE="$HOME/glpi_db.creds" setup_mariadb_db msg_info "Installing GLPi" cd /opt @@ -85,9 +71,9 @@ msg_ok "Configured Downstream file" msg_info "Configuring GLPI Database" $STD /usr/bin/php /opt/glpi/bin/console db:install \ --db-host=localhost \ - --db-name=$DB_NAME \ - --db-user=$DB_USER \ - --db-password=$DB_PASS \ + --db-name=glpi_db \ + --db-user=glpi \ + --db-password=$MARIADB_DB_PASS \ --default-language=en_US \ --no-interaction \ --allow-superuser \ diff --git a/install/keycloak-install.sh b/install/keycloak-install.sh index ce0a1cfd4..4feb8958c 100644 --- a/install/keycloak-install.sh +++ b/install/keycloak-install.sh @@ -16,14 +16,7 @@ update_os JAVA_VERSION=21 setup_java PG_VERSION=16 setup_postgresql -msg_info "Configuring PostgreSQL" -DB_NAME="keycloak" -DB_USER="keycloak" -DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" -$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8';" -$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;" -msg_ok "Configured PostgreSQL" +PG_DB_NAME="keycloak" PG_DB_USER="keycloak" setup_postgresql_db fetch_and_deploy_gh_release "keycloak_app" "keycloak/keycloak" "prebuild" "latest" "/opt/keycloak" "keycloak-*.tar.gz" @@ -43,8 +36,8 @@ Restart=always RestartSec=3 Environment="JAVA_HOME=/usr/lib/jvm/temurin-21-jdk-$(arch_resolve)" Environment="KC_DB=postgres" -Environment="KC_DB_USERNAME=$DB_USER" -Environment="KC_DB_PASSWORD=$DB_PASS" +Environment="KC_DB_USERNAME=keycloak" +Environment="KC_DB_PASSWORD=$PG_DB_PASS" Environment="KC_HTTP_ENABLED=true" Environment="KC_BOOTSTRAP_ADMIN_USERNAME=tmpadm" Environment="KC_BOOTSTRAP_ADMIN_PASSWORD=admin123" diff --git a/install/kimai-install.sh b/install/kimai-install.sh index 1531abf14..be054803d 100644 --- a/install/kimai-install.sh +++ b/install/kimai-install.sh @@ -25,21 +25,8 @@ setup_mariadb PHP_VERSION="8.4" PHP_APACHE="YES" setup_php setup_composer -msg_info "Setting up database" -DB_NAME=kimai_db -DB_USER=kimai -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) MYSQL_VERSION=$(mariadb --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') -$STD mariadb -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" -$STD mariadb -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" -cat <~/kimai.creds -Kimai-Credentials -Kimai Database User: $DB_USER -Kimai Database Password: $DB_PASS -Kimai Database Name: $DB_NAME -EOF -msg_ok "Set up database" +MARIADB_DB_NAME="kimai_db" MARIADB_DB_USER="kimai" setup_mariadb_db fetch_and_deploy_gh_release "kimai" "kimai/kimai" "tarball" @@ -50,7 +37,7 @@ echo "export COMPOSER_ALLOW_SUPERUSER=1" >>~/.bashrc source ~/.bashrc $STD composer install --no-dev --optimize-autoloader --no-interaction cp .env.dist .env -sed -i "/^DATABASE_URL=.*/c\DATABASE_URL=mysql://$DB_USER:$DB_PASS@127.0.0.1:3306/$DB_NAME?charset=utf8mb4&serverVersion=mariadb-$MYSQL_VERSION" /opt/kimai/.env +sed -i "/^DATABASE_URL=.*/c\DATABASE_URL=mysql://kimai:$MARIADB_DB_PASS@127.0.0.1:3306/kimai_db?charset=utf8mb4&serverVersion=mariadb-$MYSQL_VERSION" /opt/kimai/.env sed -i "s|^APP_SECRET=.*|APP_SECRET=$APP_SECRET|" /opt/kimai/.env $STD bin/console kimai:install -n $STD expect <~/limesurvey.creds -LimeSurvey-Credentials -LimeSurvey Database User: $DB_USER -LimeSurvey Database Password: $DB_PASS -LimeSurvey Database Name: $DB_NAME -EOF -msg_ok "Configured MariaDB Database" +MARIADB_DB_NAME="limesurvey_db" MARIADB_DB_USER="limesurvey" setup_mariadb_db msg_info "Setting up LimeSurvey" temp_file=$(mktemp) diff --git a/install/listmonk-install.sh b/install/listmonk-install.sh index f1fed7ec3..22d77fce0 100644 --- a/install/listmonk-install.sh +++ b/install/listmonk-install.sh @@ -15,26 +15,14 @@ update_os PG_VERSION="17" setup_postgresql -msg_info "Configuring PostgreSQL" -DB_NAME=listmonk -DB_USER=listmonk -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) -$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" -cat <~/listmonk.creds -listmonk-Credentials -listmonk Database User: $DB_USER -listmonk Database Password: $DB_PASS -listmonk Database Name: $DB_NAME -EOF -msg_ok "Configured PostgreSQL" +PG_DB_NAME="listmonk" PG_DB_USER="listmonk" setup_postgresql_db fetch_and_deploy_gh_release "listmonk" "knadh/listmonk" "prebuild" "latest" "/opt/listmonk" "listmonk*linux_$(arch_resolve).tar.gz" msg_info "Configuring listmonk" mkdir -p /opt/listmonk/uploads $STD /opt/listmonk/listmonk --new-config --config /opt/listmonk/config.toml -sed -i -e 's/address = "localhost:9000"/address = "0.0.0.0:9000"/' -e 's/^password = ".*"/password = "'"$DB_PASS"'"/' /opt/listmonk/config.toml +sed -i -e 's/address = "localhost:9000"/address = "0.0.0.0:9000"/' -e 's/^password = ".*"/password = "'"$PG_DB_PASS"'"/' /opt/listmonk/config.toml $STD /opt/listmonk/listmonk --install --yes --config /opt/listmonk/config.toml msg_ok "Configured listmonk" diff --git a/install/managemydamnlife-install.sh b/install/managemydamnlife-install.sh index 9001ebb10..1bb3b15dc 100644 --- a/install/managemydamnlife-install.sh +++ b/install/managemydamnlife-install.sh @@ -20,31 +20,18 @@ msg_ok "Installed dependencies" NODE_VERSION="22" setup_nodejs setup_mariadb -msg_info "Setting up Database" -DB_NAME="mmdl" -DB_USER="mmdl" -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) -$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED by '$DB_PASS';" -$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" -cat <~/mmdl.creds -Manage My Damn Life Credentials -Database User: $DB_USER -Database Password: $DB_PASS -Database Name: $DB_NAME -EOF -msg_ok "Set up Database" +MARIADB_DB_NAME="mmdl" MARIADB_DB_USER="mmdl" MARIADB_DB_CREDS_FILE="$HOME/mmdl.creds" setup_mariadb_db fetch_and_deploy_gh_release "mmdl" "intri-in/manage-my-damn-life-nextjs" "tarball" msg_info "Configuring ${APPLICATION}" cp /opt/mmdl/sample.env.local /opt/mmdl/.env sed -i -e 's|db|localhost|' \ - -e "s|myuser|${DB_USER}|" \ - -e "s|mypassword|${DB_PASS}|" \ + -e "s|myuser|mmdl|" \ + -e "s|mypassword|${MARIADB_DB_PASS}|" \ -e 's|5433|3306|' \ -e 's|DB_DIALECT=postgres|DB_DIALECT=mysql|' \ - -e "s|sample_install_mmdm|${DB_NAME}|" \ + -e "s|sample_install_mmdm|mmdl|" \ -e "s|=PASSWORD|=$(openssl rand -base64 40 | tr -dc 'a-zA-Z0-9' | head -c40)|" \ /opt/mmdl/.env cd /opt/mmdl diff --git a/install/mattermost-install.sh b/install/mattermost-install.sh index 3b698abd7..e7c8fcf1a 100644 --- a/install/mattermost-install.sh +++ b/install/mattermost-install.sh @@ -26,22 +26,7 @@ fi PG_VERSION="16" setup_postgresql -msg_info "Setting up PostgreSQL" -DB_NAME=mattermost -DB_USER=mmuser -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;" -$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH 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 DATABASE $DB_NAME OWNER TO $DB_USER;" -$STD sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO $DB_USER;" -cat <~/mattermost.creds -Mattermost Credentials -Database User: $DB_USER -Database Password: $DB_PASS -Database Name: $DB_NAME -EOF -msg_ok "Set up PostgreSQL" +PG_DB_NAME="mattermost" PG_DB_USER="mmuser" setup_postgresql_db msg_info "Installing Mattermost" curl -fsSL -o /usr/share/keyrings/mattermost-archive-keyring.gpg https://deb.packages.mattermost.com/pubkey.gpg @@ -49,7 +34,7 @@ sh -c 'curl -fsSL https://deb.packages.mattermost.com/repo-setup.sh | sudo bash apt_update_safe $STD apt install -y mattermost $STD install -C -m 600 -o mattermost -g mattermost /opt/mattermost/config/config.defaults.json /opt/mattermost/config/config.json -sed -i -e "/DataSource/c\ \"DataSource\": \"postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME?sslmode=disable&connect_timeout=10\"," \ +sed -i -e "/DataSource/c\ \"DataSource\": \"postgres://mmuser:$PG_DB_PASS@localhost:5432/mattermost?sslmode=disable&connect_timeout=10\"," \ -e "/SiteURL/c\ \"SiteURL\": \"http://$LOCAL_IP:8065\"," /opt/mattermost/config/config.json systemctl enable -q --now mattermost msg_ok "Installed Mattermost" diff --git a/install/mediamanager-install.sh b/install/mediamanager-install.sh index 6f9326e3c..3419ac30e 100644 --- a/install/mediamanager-install.sh +++ b/install/mediamanager-install.sh @@ -22,20 +22,7 @@ setup_yq NODE_VERSION="24" setup_nodejs PG_VERSION="17" setup_postgresql -msg_info "Setting up PostgreSQL" -DB_NAME="mm_db" -DB_USER="mm_user" -DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" -$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" -cat <~/mediamanager.creds -MediaManager Credentials -MediaManager Database User: $DB_USER -MediaManager Database Password: $DB_PASS -MediaManager Database Name: $DB_NAME -EOF -msg_ok "Set up PostgreSQL" +PG_DB_NAME="mm_db" PG_DB_USER="mm_user" setup_postgresql_db fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager" UV_PROJECT_DIR="/opt/mediamanager" setup_uv @@ -65,9 +52,9 @@ SECRET="$(openssl rand -hex 32)" sed -e "s/localhost:8/$LOCAL_IP:8/g" \ -e "s|/data/|$MEDIA_DIR/|g" \ -e 's/"db"/"localhost"/' \ - -e "s/user = \"MediaManager\"/user = \"$DB_USER\"/" \ - -e "s/password = \"MediaManager\"/password = \"$DB_PASS\"/" \ - -e "s/dbname = \"MediaManager\"/dbname = \"$DB_NAME\"/" \ + -e "s/user = \"MediaManager\"/user = \"mm_user\"/" \ + -e "s/password = \"MediaManager\"/password = \"$PG_DB_PASS\"/" \ + -e "s/dbname = \"MediaManager\"/dbname = \"mm_db\"/" \ -e "/^token_secret/s/=.*/= \"$SECRET\"/" \ -e "s/admin@example.com/$EMAIL/" \ -e '/^admin_emails/s/, .*/]/' \ diff --git a/install/odoo-install.sh b/install/odoo-install.sh index 0f5058f72..f68781ae7 100644 --- a/install/odoo-install.sh +++ b/install/odoo-install.sh @@ -29,29 +29,14 @@ curl -fsSL https://nightly.odoo.com/${RELEASE}/nightly/deb/odoo_${RELEASE}.lates $STD apt install -y /opt/odoo.deb msg_ok "Setup Odoo $RELEASE" -msg_info "Setup PostgreSQL Database" -DB_NAME="odoo" -DB_USER="odoo_usr" -DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;" -$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH 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 DATABASE $DB_NAME OWNER TO $DB_USER;" -$STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;" -cat <~/odoo.creds -Odoo-Credentials -Odoo Database User: $DB_USER -Odoo Database Password: $DB_PASS -Odoo Database Name: $DB_NAME -EOF -msg_ok "Setup PostgreSQL" +PG_DB_NAME="odoo" PG_DB_USER="odoo_usr" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db msg_info "Configuring Odoo" sed -i \ -e "s|^;*db_host *=.*|db_host = localhost|" \ -e "s|^;*db_port *=.*|db_port = 5432|" \ - -e "s|^;*db_user *=.*|db_user = $DB_USER|" \ - -e "s|^;*db_password *=.*|db_password = $DB_PASS|" \ + -e "s|^;*db_user *=.*|db_user = odoo_usr|" \ + -e "s|^;*db_password *=.*|db_password = $PG_DB_PASS|" \ /etc/odoo/odoo.conf $STD sudo -u odoo odoo -c /etc/odoo/odoo.conf -d odoo -i base --stop-after-init rm -f /opt/odoo.deb diff --git a/install/onlyoffice-install.sh b/install/onlyoffice-install.sh index 3460cffa0..010f0136e 100644 --- a/install/onlyoffice-install.sh +++ b/install/onlyoffice-install.sh @@ -21,22 +21,7 @@ msg_ok "Installed Dependencies" PG_VERSION="16" setup_postgresql -msg_info "Setup Database" -DB_NAME=onlyoffice -DB_USER=onlyoffice_user -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) -$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" -cat <~/onlyoffice.creds -ONLYOFFICE-Credentials -ONLYOFFICE Database User: $DB_USER -ONLYOFFICE Database Password: $DB_PASS -ONLYOFFICE Database Name: $DB_NAME -EOF -msg_ok "Set up Database" +PG_DB_NAME="onlyoffice" PG_DB_USER="onlyoffice_user" setup_postgresql_db msg_info "Adding ONLYOFFICE GPG Key" GPG_TMP="/tmp/onlyoffice.gpg" @@ -72,16 +57,16 @@ $STD rabbitmqctl set_permissions -p / $RMQ_USER ".*" ".*" ".*" $STD rabbitmqctl set_user_tags $RMQ_USER administrator echo onlyoffice-documentserver onlyoffice/db-host string localhost | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-user string $DB_USER | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-pwd password $DB_PASS | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-name string $DB_NAME | debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-user string onlyoffice_user | debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-pwd password $PG_DB_PASS | debconf-set-selections +echo onlyoffice-documentserver onlyoffice/db-name string onlyoffice | debconf-set-selections echo onlyoffice-documentserver onlyoffice/rabbitmq-host string localhost | debconf-set-selections echo onlyoffice-documentserver onlyoffice/rabbitmq-user string $RMQ_USER | debconf-set-selections echo onlyoffice-documentserver onlyoffice/rabbitmq-pwd password $RMQ_PASS | debconf-set-selections echo onlyoffice-documentserver onlyoffice/jwt-enabled boolean true | debconf-set-selections echo onlyoffice-documentserver onlyoffice/jwt-secret password $JWT_SECRET | debconf-set-selections -cat <~/onlyoffice.creds +cat <>~/onlyoffice.creds ONLYOFFICE RabbitMQ Credentials User: $RMQ_USER diff --git a/install/paymenter-install.sh b/install/paymenter-install.sh index aff545ca9..30591f37f 100644 --- a/install/paymenter-install.sh +++ b/install/paymenter-install.sh @@ -27,28 +27,18 @@ setup_composer fetch_and_deploy_gh_release "paymenter" "paymenter/paymenter" "prebuild" "latest" "/opt/paymenter" "paymenter.tar.gz" chmod -R 755 /opt/paymenter/storage/* /opt/paymenter/bootstrap/cache/ -msg_info "Setting up database" -DB_NAME=paymenter -DB_USER=paymenter -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) mariadb-tzinfo-to-sql /usr/share/zoneinfo | mariadb mysql -$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" -$STD mariadb -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost' WITH GRANT OPTION;" -cat <~/paymenter_db.creds -Paymenter Database Credentials -Database: $DB_NAME -Username: $DB_USER -Password: $DB_PASS -EOF +MARIADB_DB_NAME="paymenter" MARIADB_DB_USER="paymenter" MARIADB_DB_CREDS_FILE="$HOME/paymenter_db.creds" setup_mariadb_db + +msg_info "Setting up database" cd /opt/paymenter cp .env.example .env $STD composer install --no-dev --optimize-autoloader --no-interaction $STD php artisan key:generate --force $STD php artisan storage:link -sed -i "s/^DB_DATABASE=.*/DB_DATABASE=${DB_NAME}/" .env -sed -i "s/^DB_USERNAME=.*/DB_USERNAME=${DB_USER}/" .env -sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=${DB_PASS}/" .env +sed -i "s/^DB_DATABASE=.*/DB_DATABASE=paymenter/" .env +sed -i "s/^DB_USERNAME=.*/DB_USERNAME=paymenter/" .env +sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=${MARIADB_DB_PASS}/" .env $STD php artisan migrate --force --seed msg_ok "Set up database" diff --git a/install/planka-install.sh b/install/planka-install.sh index 4f5c59fed..0db31f12a 100644 --- a/install/planka-install.sh +++ b/install/planka-install.sh @@ -23,22 +23,7 @@ msg_ok "Installed dependencies" NODE_VERSION="24" setup_nodejs PG_VERSION="16" setup_postgresql -msg_info "Setting up PostgreSQL Database" -DB_NAME=planka -DB_USER=planka -DB_PASS=$(openssl rand -base64 16 | tr -d '/+=') -$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" -$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" -$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" -cat <~/planka.creds -PLANKA DB Credentials -PLANKA Database User: $DB_USER -PLANKA Database Password: $DB_PASS -PLANKA Database Name: $DB_NAME -EOF -msg_ok "Set up PostgreSQL Database" +PG_DB_NAME="planka" PG_DB_USER="planka" setup_postgresql_db fetch_and_deploy_gh_release "planka" "plankanban/planka" "prebuild" "latest" "/opt/planka" "planka-prebuild.zip" @@ -48,7 +33,7 @@ cd /opt/planka $STD npm install cp .env.sample .env sed -i "s#http://localhost:1337#http://$LOCAL_IP:1337#g" /opt/planka/.env -sed -i "s#postgres@localhost#planka:$DB_PASS@localhost#g" /opt/planka/.env +sed -i "s#postgres@localhost#planka:$PG_DB_PASS@localhost#g" /opt/planka/.env sed -i "s#notsecretkey#$SECRET_KEY#g" /opt/planka/.env mkdir -p /opt/planka/data/protected/{favicons,user-avatars,background-images} /opt/planka/data/private/attachments $STD npm run db:init @@ -67,7 +52,7 @@ echo "DEFAULT_ADMIN_NAME=$ADMIN_NAME" >>.env echo "DEFAULT_ADMIN_USERNAME=$ADMIN_USERNAME" >>.env $STD npm run db:seed sed -i '/# Temporary admin user creation settings/,$d' .env -cat <~/planka.creds +cat <>~/planka.creds PLANKA Admin Credentials Admin Email: $ADMIN_EMAIL diff --git a/install/pterodactyl-panel-install.sh b/install/pterodactyl-panel-install.sh index a4d0a6744..fb7bed6ed 100644 --- a/install/pterodactyl-panel-install.sh +++ b/install/pterodactyl-panel-install.sh @@ -45,20 +45,7 @@ $STD apt install -y \ libapache2-mod-php8.4 msg_ok "Installed PHP" -msg_info "Setting up MariaDB" -DB_NAME=panel -DB_USER=pterodactyl -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) -$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" -$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" -cat <~/pterodactyl-panel.creds -pterodactyl Panel-Credentials -pterodactyl Panel Database User: $DB_USER -pterodactyl Panel Database Password: $DB_PASS -pterodactyl Panel Database Name: $DB_NAME -EOF -msg_ok "Set up MariaDB" +MARIADB_DB_NAME="panel" MARIADB_DB_USER="pterodactyl" MARIADB_DB_CREDS_FILE="$HOME/pterodactyl-panel.creds" setup_mariadb_db read -p "${TAB3}Provide an email address for admin login, this should be a valid email address: " ADMIN_EMAIL read -p "${TAB3}Enter your First Name: " NAME_FIRST @@ -75,14 +62,14 @@ ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) $STD composer install --no-dev --optimize-autoloader --no-interaction $STD php artisan key:generate --force $STD php artisan p:environment:setup --no-interaction --author "$ADMIN_EMAIL" --url "http://$LOCAL_IP" -$STD php artisan p:environment:database --no-interaction --database $DB_NAME --username $DB_USER --password "$DB_PASS" +$STD php artisan p:environment:database --no-interaction --database panel --username pterodactyl --password "$MARIADB_DB_PASS" $STD php artisan migrate --seed --force --no-interaction $STD php artisan p:user:make --no-interaction --admin=1 --email "$ADMIN_EMAIL" --password "$ADMIN_PASS" --name-first "$NAME_FIRST" --name-last "$NAME_LAST" --username "admin" echo "* * * * * php /opt/pterodactyl-panel/artisan schedule:run >> /dev/null 2>&1" | crontab -u www-data - chown -R www-data:www-data /opt/pterodactyl-panel/* chmod -R 755 /opt/pterodactyl-panel/storage/* /opt/pterodactyl-panel/bootstrap/cache/ ln -s /opt/pterodactyl-panel /var/www/pterodactyl -cat <~/pterodactyl-panel.creds +cat <>~/pterodactyl-panel.creds pterodactyl Admin Username: admin pterodactyl Admin Email: $ADMIN_EMAIL