-
-
Notifications
You must be signed in to change notification settings - Fork 133
Add snowshare #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add snowshare #1063
Changes from 7 commits
b17aebe
abef124
2fe4119
21d595d
17c7791
50eaac6
c8b36f3
28b6a60
77a82c7
24ddf4f
a5ba34b
89a062b
89d5c09
477ae6c
a44c936
f8c397c
896299a
a39be23
8535e8b
21b7d27
24832bc
a5a59fc
300c235
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #!/usr/bin/env bash | ||
| source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) | ||
|
|
||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #source <(curl -fsSL https://raw.githubusercontent.com/TuroYT/ProxmoxVED/refs/heads/add-snowshare/misc/build.func) | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Copyright (c) 2021-2025 community-scripts ORG | ||
| # Author: TuroYT | ||
| # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | ||
| # Source: https://github.com/TuroYT/snowshare | ||
|
|
||
| APP="SnowShare" | ||
| var_tags="${var_tags:-file-sharing}" | ||
| var_cpu="${var_cpu:-1}" | ||
| var_ram="${var_ram:-1024}" | ||
| var_disk="${var_disk:-5}" | ||
| var_os="${var_os:-debian}" | ||
| var_version="${var_version:-12}" | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var_unprivileged="${var_unprivileged:-1}" | ||
|
|
||
| header_info "$APP" | ||
|
|
||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| variables | ||
| color | ||
| catch_errors | ||
|
|
||
| function update_script() { | ||
| header_info | ||
| check_container_storage | ||
| check_container_resources | ||
| if [[ ! -d /opt/snowshare ]]; then | ||
| msg_error "No ${APP} Installation Found!" | ||
| exit | ||
| fi | ||
|
|
||
| # S'assurer que jq est installé pour l'analyse de l'API | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if ! command -v jq &> /dev/null; then | ||
| msg_info "Installing 'jq' (required for update check)..." | ||
| apt-get update &>/dev/null | ||
| apt-get install -y jq &>/dev/null | ||
| if ! command -v jq &> /dev/null; then | ||
| msg_error "Failed to install 'jq'. Cannot proceed with update." | ||
| exit 1 | ||
| fi | ||
| msg_ok "Installed 'jq'" | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| msg_info "Checking for ${APP} updates..." | ||
| cd /opt/snowshare | ||
|
|
||
| # Obtenir le tag local actuel | ||
| CURRENT_TAG=$(git describe --tags 2>/dev/null) | ||
| if [ $? -ne 0 ]; then | ||
| msg_warn "Could not determine current version tag. Fetching latest..." | ||
| CURRENT_TAG="unknown" | ||
| fi | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Obtenir le tag de la dernière release depuis GitHub | ||
| LATEST_TAG=$(curl -s "https://api.github.com/repos/TuroYT/snowshare/releases/latest" | jq -r .tag_name) | ||
|
|
||
| if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" == "null" ]; then | ||
| msg_error "Failed to fetch the latest release tag from GitHub." | ||
| exit 1 | ||
| fi | ||
|
|
||
| msg_info "Current version: $CURRENT_TAG" | ||
| msg_info "Latest version: $LATEST_TAG" | ||
|
|
||
| if [ "$CURRENT_TAG" == "$LATEST_TAG" ]; then | ||
| msg_ok "${APP} is already up to date." | ||
| exit | ||
| fi | ||
|
||
|
|
||
| msg_info "Updating ${APP} to $LATEST_TAG..." | ||
|
||
| systemctl stop snowshare | ||
|
|
||
| # Récupérer les nouveaux tags | ||
| git fetch --tags | ||
|
||
|
|
||
| # Se placer sur le dernier tag | ||
| git checkout $LATEST_TAG | ||
| if [ $? -ne 0 ]; then | ||
| msg_error "Failed to checkout tag $LATEST_TAG. Aborting update." | ||
| systemctl start snowshare | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Relancer les étapes d'installation et de build | ||
| msg_info "Installing dependencies..." | ||
| npm ci | ||
| msg_info "Generating Prisma client..." | ||
|
||
| npx prisma generate | ||
| msg_info "Applying database migrations..." | ||
| npx prisma migrate deploy # Important pour les changements de schéma | ||
| msg_info "Building application..." | ||
| npm run build | ||
|
|
||
| systemctl start snowshare | ||
| msg_ok "Updated ${APP} to $LATEST_TAG" | ||
| exit | ||
| } | ||
|
|
||
| start | ||
| build_container | ||
| description | ||
|
|
||
| msg_ok "Completed Successfully!\n" | ||
| echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" | ||
| echo -e "${INFO}${YW} Access it using the following URL:${CL}" | ||
| echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "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": [] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright (c) 2021-2025 community-scripts ORG | ||
| # Author: TuroYT | ||
| # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | ||
|
|
||
| source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" | ||
| color | ||
| verb_ip6 | ||
| catch_errors | ||
| setting_up_container | ||
| network_check | ||
| update_os | ||
|
|
||
| msg_info "Installing Dependencies" | ||
| $STD apt-get install -y \ | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| curl \ | ||
| sudo \ | ||
| git \ | ||
| jq \ | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| make \ | ||
| gnupg \ | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ca-certificates \ | ||
| postgresql \ | ||
| postgresql-contrib | ||
| msg_ok "Installed Dependencies" | ||
|
|
||
| msg_info "Installing Node.js" | ||
| 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" | ||
| DB_NAME=snowshare | ||
| DB_USER=snowshare | ||
| DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" | ||
| systemctl enable -q --now postgresql | ||
| $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 | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| msg_ok "Set up PostgreSQL Database" | ||
TuroYT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| msg_info "Installing SnowShare (Patience)" | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Find the latest release tag using the GitHub API | ||
| LATEST_TAG=$(curl -s "https://api.github.com/repos/TuroYT/snowshare/releases/latest" | jq -r .tag_name) | ||
|
|
||
| if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" == "null" ]; then | ||
| msg_error "Failed to fetch the latest release tag from GitHub." | ||
| exit 1 | ||
| fi | ||
| msg_ok "Fetching latest release: $LATEST_TAG" | ||
|
|
||
| cd /opt | ||
| $STD git clone https://github.com/TuroYT/snowshare.git | ||
| cd /opt/snowshare | ||
| $STD git checkout $LATEST_TAG | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| msg_ok "Checked out $LATEST_TAG" | ||
|
|
||
| $STD npm ci | ||
| msg_ok "Installed SnowShare dependencies" | ||
|
|
||
| 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 "Created Environment Configuration" | ||
|
|
||
| msg_info "Running Database Migrations" | ||
| cd /opt/snowshare | ||
| $STD npx prisma generate | ||
| $STD npx prisma migrate deploy | ||
| msg_ok "Ran Database Migrations" | ||
|
|
||
| msg_info "Building SnowShare" | ||
| cd /opt/snowshare | ||
| $STD npm run build | ||
| msg_ok "Built SnowShare" | ||
|
|
||
| msg_info "Creating 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 | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| WorkingDirectory=/opt/snowshare | ||
| Environment=NODE_ENV=production | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ExecStart=/usr/bin/npm start | ||
| Restart=on-failure | ||
| RestartSec=10 | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
| systemctl enable -q --now snowshare.service | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| msg_ok "Created Service" | ||
|
|
||
| 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 | ||
TuroYT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| customize | ||
|
|
||
| msg_info "Cleaning up" | ||
TuroYT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $STD apt-get -y autoremove | ||
| $STD apt-get -y autoclean | ||
TuroYT marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| msg_ok "Cleaned" | ||
Uh oh!
There was an error while loading. Please reload this page.