This commit is contained in:
Romain PINSOLLE 2025-10-31 09:38:37 +00:00
parent 17c77913e2
commit 24ddf4fc34
3 changed files with 42 additions and 43 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) #source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
#source <(curl -fsSL https://raw.githubusercontent.com/TuroYT/ProxmoxVED/refs/heads/add-snowshare/misc/build.func) source <(curl -fsSL https://raw.githubusercontent.com/TuroYT/ProxmoxVED/refs/heads/add-snowshare/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG # Copyright (c) 2021-2025 community-scripts ORG
# Author: TuroYT # Author: TuroYT
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@ -13,7 +13,7 @@ var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-1024}" var_ram="${var_ram:-1024}"
var_disk="${var_disk:-5}" var_disk="${var_disk:-5}"
var_os="${var_os:-debian}" var_os="${var_os:-debian}"
var_version="${var_version:-12}" var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}" var_unprivileged="${var_unprivileged:-1}"
header_info "$APP" header_info "$APP"
@ -30,16 +30,25 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
msg_info "Updating ${APP}"
if check_for_gh_release "snowshare" "TuroYT/snowshare"; then
msg_info "Updating ${APP} to v${RELEASE}"
systemctl stop snowshare systemctl stop snowshare
cd /opt/
fetch_and_deploy_gh_release "snowshare" "TuroYT/snowshare"
cd /opt/snowshare cd /opt/snowshare
git pull
npm ci npm ci
npx prisma generate npx prisma generate
npm run build npm run build
systemctl start snowshare systemctl start snowshare
msg_ok "Updated ${APP}" msg_ok "Updated ${APP}"
exit exit
else
msg_ok "No update required. ${APP} is already at v${RELEASE}."
fi
exit
} }
start start

View File

@ -23,7 +23,7 @@
"ram": 1024, "ram": 1024,
"hdd": 5, "hdd": 5,
"os": "Debian", "os": "Debian",
"version": "12" "version": "13"
} }
} }
], ],

View File

@ -14,48 +14,41 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt-get install -y \
curl \
sudo \
git \
make \ make \
gnupg \ gnupg \
ca-certificates \ ca-certificates
postgresql \
postgresql-contrib
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Installing Node.js" setup_nodejs
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
$STD apt-get update
$STD apt-get install -y nodejs
msg_ok "Installed Node.js $(node -v)"
msg_info "Setting up PostgreSQL Database" msg_info "Setting up PostgreSQL Database"
DB_NAME=snowshare DB_NAME=snowshare
DB_USER=snowshare DB_USER=snowshare
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
systemctl enable -q --now postgresql setup_postgresql
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" $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 "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 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 default_transaction_isolation TO 'read committed';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';" $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
echo "" >>~/snowshare.creds echo "" >>~/snowshare.creds
echo -e "SnowShare Database User: \e[32m$DB_USER\e[0m" >>~/snowshare.creds echo -e "Database Username: $DB_USER" >>~/snowshare.creds
echo -e "SnowShare Database Password: \e[32m$DB_PASS\e[0m" >>~/snowshare.creds echo -e "Database Password: $DB_PASS" >>~/snowshare.creds
echo -e "SnowShare Database Name: \e[32m$DB_NAME\e[0m" >>~/snowshare.creds echo -e "Database Name: $DB_NAME" >>~/snowshare.creds
msg_ok "Set up PostgreSQL Database" msg_ok "Set up PostgreSQL Database"
msg_info "Installing SnowShare (Patience)" msg_info "Installing SnowShare (Patience)"
APP="snowshare"
cd /opt cd /opt
$STD git clone https://github.com/TuroYT/snowshare.git
fetch_and_deploy_gh_release "snowshare" "TuroYT/snowshare"
cd /opt/snowshare cd /opt/snowshare
$STD npm ci $STD npm ci
msg_ok "Installed SnowShare"
msg_info "Creating Environment Configuration" echo "${RELEASE}" >/opt/${APP}_version.txt
cat <<EOF >/opt/snowshare/.env cat <<EOF >/opt/snowshare/.env
DATABASE_URL="postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME" DATABASE_URL="postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME"
NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_URL="http://localhost:3000"
@ -63,18 +56,14 @@ NEXTAUTH_SECRET="$(openssl rand -base64 32)"
ALLOW_SIGNUP=true ALLOW_SIGNUP=true
NODE_ENV=production NODE_ENV=production
EOF EOF
msg_ok "Created Environment Configuration"
msg_info "Running Database Migrations"
cd /opt/snowshare cd /opt/snowshare
$STD npx prisma generate $STD npx prisma generate
$STD npx prisma migrate deploy $STD npx prisma migrate deploy
msg_ok "Ran Database Migrations" msg_ok "Ran Database Migrations"
msg_info "Building SnowShare"
cd /opt/snowshare cd /opt/snowshare
$STD npm run build $STD npm run build
msg_ok "Built SnowShare"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/snowshare.service cat <<EOF >/etc/systemd/system/snowshare.service
@ -96,7 +85,7 @@ RestartSec=10
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now snowshare.service systemctl enable -q --now snowshare.service
msg_ok "Created Service" msg_ok "Installed SnowShare v${RELEASE}"
msg_info "Setting up Cleanup Cron Job" msg_info "Setting up Cleanup Cron Job"
cat <<EOF >/etc/cron.d/snowshare-cleanup cat <<EOF >/etc/cron.d/snowshare-cleanup
@ -108,6 +97,7 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
$STD apt-get -y autoremove $STD apt -y autoremove
$STD apt-get -y autoclean $STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned" msg_ok "Cleaned"