add snowshare

This commit is contained in:
Romain PINSOLLE 2025-10-30 10:56:46 +00:00
parent 23e08b5f26
commit b17aebea60
5 changed files with 238 additions and 2 deletions

79
ct/snowshare.sh Normal file
View File

@ -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"

View File

@ -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": []
}

View File

@ -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 <<EOF > /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 <<EOF >/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"

View File

@ -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
}

View File

@ -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