mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-25 16:05:54 +00:00
some fix
This commit is contained in:
@@ -1,93 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Couleurs pour les messages
|
||||
YW=$(echo "\033[33m")
|
||||
BL=$(echo "\033[36m")
|
||||
RD=$(echo "\033[01;31m")
|
||||
BGN=$(echo "\033[4;92m")
|
||||
GN=$(echo "\033[1;92m")
|
||||
DGN=$(echo "\033[32m")
|
||||
CL=$(echo "\033[m")
|
||||
BFR="\\r\\033[K"
|
||||
HOLD="-"
|
||||
CM="${GN}✓${CL}"
|
||||
CROSS="${RD}✗${CL}"
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
# Author: TuroYT
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
|
||||
msg_info() {
|
||||
local msg="$1"
|
||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
||||
}
|
||||
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
||||
color
|
||||
verb_ip6
|
||||
catch_errors
|
||||
setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_ok() {
|
||||
local msg="$1"
|
||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||
}
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt-get install -y \
|
||||
curl \
|
||||
sudo \
|
||||
git \
|
||||
make \
|
||||
gnupg \
|
||||
ca-certificates \
|
||||
postgresql \
|
||||
postgresql-contrib
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_error() {
|
||||
local msg="$1"
|
||||
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||
}
|
||||
|
||||
# Installation des dépendances système
|
||||
msg_info "Updating system packages"
|
||||
apt-get update &>/dev/null
|
||||
apt-get upgrade -y &>/dev/null
|
||||
msg_ok "Updated system packages"
|
||||
|
||||
msg_info "Installing dependencies"
|
||||
apt-get install -y curl sudo git wget postgresql postgresql-contrib &>/dev/null
|
||||
msg_ok "Installed dependencies"
|
||||
|
||||
# Installation de Node.js 20
|
||||
msg_info "Installing Node.js"
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - &>/dev/null
|
||||
apt-get install -y nodejs &>/dev/null
|
||||
msg_ok "Installed Node.js $(node --version)"
|
||||
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)"
|
||||
|
||||
# Configuration de PostgreSQL
|
||||
msg_info "Configuring PostgreSQL"
|
||||
systemctl enable --now postgresql &>/dev/null
|
||||
sudo -u postgres psql -c "CREATE DATABASE snowshare;" &>/dev/null
|
||||
sudo -u postgres psql -c "CREATE USER snowshare WITH ENCRYPTED PASSWORD 'snowshare';" &>/dev/null
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE snowshare TO snowshare;" &>/dev/null
|
||||
sudo -u postgres psql -c "ALTER DATABASE snowshare OWNER TO snowshare;" &>/dev/null
|
||||
msg_ok "Configured PostgreSQL"
|
||||
msg_info "Setting up PostgreSQL Database"
|
||||
DB_NAME=snowshare
|
||||
DB_USER=snowshare
|
||||
DB_PASS="$(openssl rand -base64 18 | 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'"
|
||||
echo "" >>~/snowshare.creds
|
||||
echo -e "SnowShare Database User: \e[32m$DB_USER\e[0m" >>~/snowshare.creds
|
||||
echo -e "SnowShare Database Password: \e[32m$DB_PASS\e[0m" >>~/snowshare.creds
|
||||
echo -e "SnowShare Database Name: \e[32m$DB_NAME\e[0m" >>~/snowshare.creds
|
||||
msg_ok "Set up PostgreSQL Database"
|
||||
|
||||
# Clonage du dépôt
|
||||
msg_info "Cloning SnowShare repository"
|
||||
git clone https://github.com/TuroYT/snowshare.git /opt/snowshare &>/dev/null
|
||||
msg_info "Installing SnowShare (Patience)"
|
||||
cd /opt
|
||||
RELEASE=$(curl -s https://api.github.com/repos/TuroYT/snowshare/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
$STD git clone https://github.com/TuroYT/snowshare.git
|
||||
cd /opt/snowshare
|
||||
msg_ok "Cloned repository"
|
||||
$STD npm ci
|
||||
msg_ok "Installed SnowShare"
|
||||
|
||||
# Installation des dépendances NPM
|
||||
msg_info "Installing NPM dependencies"
|
||||
npm ci &>/dev/null
|
||||
msg_ok "Installed NPM dependencies"
|
||||
|
||||
# Configuration de l'environnement
|
||||
msg_info "Configuring environment"
|
||||
cat <<EOF > /opt/snowshare/.env
|
||||
DATABASE_URL="postgresql://snowshare:snowshare@localhost:5432/snowshare"
|
||||
msg_info "Creating Environment Configuration"
|
||||
cat <<EOF >/opt/snowshare/.env
|
||||
DATABASE_URL="postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME"
|
||||
NEXTAUTH_URL="http://localhost:3000"
|
||||
NEXTAUTH_SECRET="$(openssl rand -base64 32)"
|
||||
ALLOW_SIGNUP=true
|
||||
NODE_ENV=production
|
||||
EOF
|
||||
msg_ok "Configured environment"
|
||||
msg_ok "Created Environment Configuration"
|
||||
|
||||
# Génération Prisma et migrations
|
||||
msg_info "Running Prisma migrations"
|
||||
npx prisma generate &>/dev/null
|
||||
npx prisma migrate deploy &>/dev/null
|
||||
msg_ok "Ran Prisma migrations"
|
||||
msg_info "Running Database Migrations"
|
||||
cd /opt/snowshare
|
||||
$STD npx prisma generate
|
||||
$STD npx prisma migrate deploy
|
||||
msg_ok "Ran Database Migrations"
|
||||
|
||||
# Build de l'application
|
||||
msg_info "Building SnowShare"
|
||||
npm run build &>/dev/null
|
||||
$STD npm run build
|
||||
msg_ok "Built SnowShare"
|
||||
|
||||
# Création du service systemd
|
||||
msg_info "Creating systemd service"
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/snowshare.service
|
||||
[Unit]
|
||||
Description=SnowShare - Modern File Sharing Platform
|
||||
@@ -106,17 +94,19 @@ RestartSec=10
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now snowshare.service &>/dev/null
|
||||
msg_ok "Created systemd service"
|
||||
systemctl enable -q --now snowshare.service
|
||||
msg_ok "Created Service"
|
||||
|
||||
# Configuration du cron pour le nettoyage
|
||||
msg_info "Setting up cleanup cron job"
|
||||
(crontab -l 2>/dev/null; echo "0 2 * * * cd /opt/snowshare && /usr/bin/npm run cleanup:expired >> /var/log/snowshare-cleanup.log 2>&1") | crontab -
|
||||
msg_ok "Setup cleanup cron job"
|
||||
msg_info "Setting up Cleanup Cron Job"
|
||||
cat <<EOF >/etc/cron.d/snowshare-cleanup
|
||||
0 2 * * * root cd /opt/snowshare && /usr/bin/npm run cleanup:expired >> /var/log/snowshare-cleanup.log 2>&1
|
||||
EOF
|
||||
msg_ok "Set up Cleanup Cron Job"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
||||
# Nettoyage
|
||||
msg_info "Cleaning up"
|
||||
apt-get autoremove -y &>/dev/null
|
||||
apt-get autoclean -y &>/dev/null
|
||||
msg_ok "Cleaned up"
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
msg_ok "Cleaned"
|
||||
Reference in New Issue
Block a user