From b17aebea6099ee9f7e36e7ea47e489c863645f55 Mon Sep 17 00:00:00 2001 From: Romain PINSOLLE Date: Thu, 30 Oct 2025 10:56:46 +0000 Subject: [PATCH] add snowshare --- ct/snowshare.sh | 79 ++++++++++++++++++ frontend/public/json/snowshare.json | 35 ++++++++ install/snowshare-install.sh | 122 ++++++++++++++++++++++++++++ misc/build.func | 2 +- misc/install.func | 2 +- 5 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 ct/snowshare.sh create mode 100644 frontend/public/json/snowshare.json create mode 100644 install/snowshare-install.sh diff --git a/ct/snowshare.sh b/ct/snowshare.sh new file mode 100644 index 000000000..816036f49 --- /dev/null +++ b/ct/snowshare.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: TuroYT +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _____ _____ __ + / ___/____ ____ _ __ / ___// /_ ____ ___________ + \__ \/ __ \/ __ \ | /| / / \__ \/ __ \/ __ `/ ___/ _ \ + ___/ / / / / /_/ / |/ |/ / ___/ / / / / /_/ / / / __/ +/____/_/ /_/\____/|__/|__/ /____/_/ /_/\__,_/_/ \___/ + +EOF +} +header_info +echo -e "Loading..." +APP="SnowShare" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/snowshare ]]; then + msg_error "No ${APP} Installation Found!" + exit +fi +msg_info "Updating ${APP}" +systemctl stop snowshare +cd /opt/snowshare +git pull +npm ci +npx prisma generate +npm run build +systemctl start snowshare +msg_ok "Updated ${APP}" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" \ No newline at end of file diff --git a/frontend/public/json/snowshare.json b/frontend/public/json/snowshare.json new file mode 100644 index 000000000..553971987 --- /dev/null +++ b/frontend/public/json/snowshare.json @@ -0,0 +1,35 @@ +{ + "name": "SnowShare", + "slug": "snowshare", + "categories": [ + 11 + ], + "date_created": "2025-09-24", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://github.com/TuroYT/snowshare", + "config_path": "/opt/snowshare/.env", + "website": "https://github.com/TuroYT/snowshare", + "logo": "https://github.com/TuroYT/snowshare/raw/main/public/logo.svg", + "description": "A modern, secure file and link sharing platform built with Next.js, Prisma, and NextAuth. Share URLs, code snippets, and files with customizable expiration, privacy, and QR codes.", + "install_methods": [ + { + "type": "default", + "script": "ct/snowshare.sh", + "resources": { + "cpu": 1, + "ram": 1024, + "hdd": 5, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file diff --git a/install/snowshare-install.sh b/install/snowshare-install.sh new file mode 100644 index 000000000..f1f82aa03 --- /dev/null +++ b/install/snowshare-install.sh @@ -0,0 +1,122 @@ +#!/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}" + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +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)" + +# 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" + +# Clonage du dépôt +msg_info "Cloning SnowShare repository" +git clone https://github.com/TuroYT/snowshare.git /opt/snowshare &>/dev/null +cd /opt/snowshare +msg_ok "Cloned repository" + +# 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 < /opt/snowshare/.env +DATABASE_URL="postgresql://snowshare:snowshare@localhost:5432/snowshare" +NEXTAUTH_URL="http://localhost:3000" +NEXTAUTH_SECRET="$(openssl rand -base64 32)" +ALLOW_SIGNUP=true +NODE_ENV=production +EOF +msg_ok "Configured environment" + +# 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" + +# Build de l'application +msg_info "Building SnowShare" +npm run build &>/dev/null +msg_ok "Built SnowShare" + +# Création du service systemd +msg_info "Creating systemd service" +cat </etc/systemd/system/snowshare.service +[Unit] +Description=SnowShare - Modern File Sharing Platform +After=network.target postgresql.service +Requires=postgresql.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/snowshare +Environment=NODE_ENV=production +ExecStart=/usr/bin/npm start +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF +systemctl daemon-reload +systemctl enable --now snowshare.service &>/dev/null +msg_ok "Created systemd 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" + +# Nettoyage +msg_info "Cleaning up" +apt-get autoremove -y &>/dev/null +apt-get autoclean -y &>/dev/null +msg_ok "Cleaned up" \ No newline at end of file diff --git a/misc/build.func b/misc/build.func index eb2183872..dcb257d75 100644 --- a/misc/build.func +++ b/misc/build.func @@ -2488,7 +2488,7 @@ EOF' install_ssh_keys_into_ct # Run application installer - if ! lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)"; then + if ! lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/TuroYT/ProxmoxVED/refs/heads/add-snowshare/install/${var_install}.sh)"; then exit $? fi } diff --git a/misc/install.func b/misc/install.func index f741b921d..84d4e6fb4 100644 --- a/misc/install.func +++ b/misc/install.func @@ -195,7 +195,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/TuroYT/ProxmoxVED/raw/add-snowshare/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh