diff --git a/ct/otterwiki.sh b/ct/otterwiki.sh new file mode 100644 index 000000000..20cbc4097 --- /dev/null +++ b/ct/otterwiki.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: CillyCil +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/redimp/otterwiki + +# App Default Values +# Name of the app (e.g. Google, Adventurelog, Apache-Guacamole" +APP="OtterWiki" +# Tags for Proxmox VE, maximum 2 pcs., no spaces allowed, separated by a semicolon ; (e.g. database | adblock;dhcp) +var_tags="${var_tags:-wiki}" +# Number of cores (1-X) (e.g. 4) - default are 2 +var_cpu="${var_cpu:-2}" +# Amount of used RAM in MB (e.g. 2048 or 4096) +var_ram="${var_ram:-2048}" +# Amount of used disk space in GB (e.g. 4 or 10) +var_disk="${var_disk:-10}" +# Default OS (e.g. debian, ubuntu, alpine) +var_os="${var_os:-debian}" +# Default OS version (e.g. 12 for debian, 24.04 for ubuntu, 3.20 for alpine) +var_version="${var_version:-12}" +# 1 = unprivileged container, 0 = privileged container +var_unprivileged="${var_unprivileged:-0}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + # Check if installation is present | -f for file, -d for folder + if [[ ! -f /opt/otterwiki ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + # Crawling the new version and checking whether an update is required + RELEASE=$(curl -fsSL https://api.github.com/repos/redimp/otterwiki/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat /opt/otterwiki_version.txt)" ]] || [[ ! -f /opt/otterwiki_version.txt ]]; then + # Stopping Services + msg_info "Stopping $APP" + systemctl stop otterwiki.service + msg_ok "Stopped $APP" + + # Creating Backup + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/otterwiki/app-data /opt/otterwiki/settings.cfg + msg_ok "Backup Created" + + # Execute Update + msg_info "Updating $APP to v${RELEASE}" + cd /opt/otterwiki/ || exit + # Update the repository information + git remote update origin + # Get the latest release tag + LATEST_RELEASE=$(git describe --tags $(git rev-list --tags --max-count=1)) + # Create a new branch named like the latest release version. + git checkout -b $LATEST_RELEASE $LATEST_RELEASE + ./venv/bin/pip install -U . + msg_ok "Updated $APP to v${RELEASE}" + + # Starting Services + msg_info "Starting $APP" + systemctl start otterwiki.service + msg_ok "Started $APP" + + # # Cleaning up + # msg_info "Cleaning Up" + # rm -rf [TEMP_FILES] + # msg_ok "Cleanup Completed" + + # Last Action + echo "${RELEASE}" >/opt/otterwiki_version.txt + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + 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}:8080${CL}" diff --git a/frontend/public/json/otterwiki.json b/frontend/public/json/otterwiki.json new file mode 100644 index 000000000..959415a75 --- /dev/null +++ b/frontend/public/json/otterwiki.json @@ -0,0 +1,40 @@ +{ + "name": "OtterWiki", + "slug": "otterwiki", + "categories": [ + 12 + ], + "date_created": "2025-08-17", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8080, + "documentation": "https://otterwiki.com/", + "config_path": "/opt/otterwiki/settings.cfg", + "website": "https://github.com/redimp/otterwiki", + "logo": "https://otterwiki.com/static/img/otterhead.png", + "description": "A minimalistic wiki powered by python, markdown and git.", + "install_methods": [ + { + "type": "default", + "script": "ct/otterwiki.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 10, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "The first account registered will be an admin account with access to the application settings.", + "type": "info" + } + ] +} diff --git a/install/otterwiki-install.sh b/install/otterwiki-install.sh new file mode 100644 index 000000000..12f4a7273 --- /dev/null +++ b/install/otterwiki-install.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: CillyCil +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/redimp/otterwiki + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +# Installing Dependencies +msg_info "Installing Dependencies" +$STD apt-get install -y \ + git \ + build-essential \ + python3-dev \ + python3-venv +msg_ok "Installed Dependencies" + +# # Template: MySQL Database +# msg_info "Setting up Database" +# DB_NAME=[DB_NAME] +# DB_USER=[DB_USER] +# DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +# $STD mysql -u root -e "CREATE DATABASE $DB_NAME;" +# $STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" +# $STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +# { +# echo "${APPLICATION} Credentials" +# echo "Database User: $DB_USER" +# echo "Database Password: $DB_PASS" +# echo "Database Name: $DB_NAME" +# } >>~/"$APP_NAME".creds +# msg_ok "Set up Database" + +# Setup App +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -fsSL https://api.github.com/repos/redimp/otterwiki/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +curl -fsSL -o "${RELEASE}.zip" "https://github.com/redimp/otterwiki/archive/refs/tags/${RELEASE}.zip" +unzip -q "${RELEASE}.zip" +mv "otterwiki-${RELEASE:1}/" "/opt/otterwiki" +cd /opt/otterwiki || exit +mkdir -p app-data/repository +# initialize the empty repository +git init -b main app-data/repository +echo "REPOSITORY='${PWD}/app-data/repository'" >> settings.cfg +echo "SQLALCHEMY_DATABASE_URI='sqlite:///${PWD}/app-data/db.sqlite'" >> settings.cfg +echo "SECRET_KEY='$(python3 -c 'import secrets; print(secrets.token_hex())')'" >> settings.cfg +python3 -m venv venv +./venv/bin/pip install -U pip uwsgi +./venv/bin/pip install . +echo "${RELEASE}" >/opt/otterwiki_version.txt +msg_ok "Setup ${APPLICATION}" + +# Creating Service (if needed) +msg_info "Creating Service" +cat </etc/systemd/system/otterwiki.service +[Unit] +Description=uWSGI server for An Otter Wiki + +[Service] +User=root +Environment=OTTERWIKI_SETTINGS=/opt/otterwiki/settings.cfg +ExecStart=/opt/otterwiki/venv/bin/uwsgi --http :8080 --enable-threads --die-on-term -w otterwiki.server:app +SyslogIdentifier=otterwiki + +[Install] +WantedBy=multi-user.target +EOF +systemctl daemon-reload +systemctl enable -q --now otterwiki +msg_ok "Created Service" + +motd_ssh +customize + +# Cleanup +msg_info "Cleaning up" +rm -f "${RELEASE}".zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"