diff --git a/ct/headers/obsidian-livesync b/ct/headers/obsidian-livesync new file mode 100644 index 000000000..5cca1dff4 --- /dev/null +++ b/ct/headers/obsidian-livesync @@ -0,0 +1,6 @@ + ____ __ _ ___ __ _ _____ + / __ \/ /_ _____(_)___/ (_)___ _____ / / (_) _____ / ___/__ ______ _____ + / / / / __ \/ ___/ / __ / / __ `/ __ \______/ / / / | / / _ \\__ \/ / / / __ \/ ___/ +/ /_/ / /_/ (__ ) / /_/ / / /_/ / / / /_____/ /___/ /| |/ / __/__/ / /_/ / / / / /__ +\____/_.___/____/_/\__,_/_/\__,_/_/ /_/ /_____/_/ |___/\___/____/\__, /_/ /_/\___/ + /____/ diff --git a/ct/obsidian-livesync.sh b/ct/obsidian-livesync.sh new file mode 100644 index 000000000..05fba03f1 --- /dev/null +++ b/ct/obsidian-livesync.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +source "$(dirname "${BASH_SOURCE[0]}")/../misc/build.func" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main}/misc/build.func") + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/vrtmrz/obsidian-livesync | https://couchdb.apache.org/ + +APP="Obsidian-LiveSync" +var_tags="${var_tags:-documents;notes}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_arm64="${var_arm64:-no}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/couchdb/etc/local.d/obsidian-livesync.ini ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Stopping CouchDB" + systemctl stop couchdb + msg_ok "Stopped CouchDB" + + create_backup /var/lib/couchdb /opt/couchdb/etc/local.d/obsidian-livesync.ini /opt/obsidian-livesync/.env + + msg_info "Updating Container OS" + $STD apt update + $STD apt upgrade -y + msg_ok "Updated Container OS" + + systemctl stop couchdb + restore_backup + + msg_info "Starting CouchDB" + systemctl start couchdb + msg_ok "Started CouchDB" + msg_ok "Updated successfully!" + 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}Configure the Self-hosted LiveSync plugin with the credentials in /opt/obsidian-livesync/.env${CL}" +echo -e "${GATEWAY}${BGN}http://${IP}:5984/_utils/${CL}" diff --git a/install/obsidian-livesync-install.sh b/install/obsidian-livesync-install.sh new file mode 100644 index 000000000..0cff907ff --- /dev/null +++ b/install/obsidian-livesync-install.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/vrtmrz/obsidian-livesync | https://couchdb.apache.org/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +setup_deb822_repo \ + "couchdb" \ + "https://couchdb.apache.org/repo/keys.asc" \ + "https://apache.jfrog.io/artifactory/couchdb-deb/" \ + "$(get_os_info codename)" \ + "main" + +msg_info "Installing CouchDB" +COUCHDB_ADMIN_USER="admin" +COUCHDB_PASSWORD="$(openssl rand -hex 24)" +COUCHDB_COOKIE="$(openssl rand -hex 16)" + +cat </root/.couchdb.credentials +COUCHDB_ADMIN_USER="${COUCHDB_ADMIN_USER}" +COUCHDB_ADMIN_PASSWORD="${COUCHDB_PASSWORD}" +COUCHDB_COOKIE="${COUCHDB_COOKIE}" +EOF +msg_ok "Installed CouchDB" + +msg_info "Configuring CouchDB" +mkdir -p /opt/couchdb/etc/local.d /opt/obsidian-livesync +cat </opt/couchdb/etc/local.d/obsidian-livesync.ini +[couchdb] +single_node = true +max_document_size = 50000000 + +[admins] +admin = ${COUCHDB_PASSWORD} + +[chttpd] +bind_address = 0.0.0.0 +port = 5984 +max_http_request_size = 4294967296 + +[chttpd_auth] +require_valid_user = true + +[httpd] +enable_cors = true +WWW-Authenticate = Basic realm="couchdb" + +[cors] +credentials = true +origins = app://obsidian.md,capacitor://localhost,http://localhost +headers = accept, authorization, content-type, origin, referer +methods = GET, PUT, POST, HEAD, DELETE +max_age = 3600 +EOF +cat </opt/obsidian-livesync/.env +COUCHDB_URL=http://${LOCAL_IP}:5984 +COUCHDB_USER=admin +COUCHDB_PASSWORD=${COUCHDB_PASSWORD} +COUCHDB_DATABASE=obsidiannotes +EOF +chmod 600 /opt/obsidian-livesync/.env +msg_ok "Configured CouchDB" + +msg_info "Creating LiveSync Database" +systemctl enable -q couchdb +systemctl restart couchdb +for _ in {1..30}; do + curl -fsS -u "admin:${COUCHDB_PASSWORD}" -X PUT http://127.0.0.1:5984/obsidiannotes >/dev/null 2>&1 && break + sleep 1 +done +msg_ok "Created LiveSync Database" + +motd_ssh +customize +cleanup_lxc