From b8f7a1ff2cace309a6524bf1186d3ad1e7a9d139 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Wed, 11 Jun 2025 09:45:05 -0400 Subject: [PATCH] OpenCloud: first commit --- ct/opencloud.sh | 62 +++++++++++++++++++++++++++++++ install/opencloud-install.sh | 72 ++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 ct/opencloud.sh create mode 100644 install/opencloud-install.sh diff --git a/ct/opencloud.sh b/ct/opencloud.sh new file mode 100644 index 00000000..12dee63a --- /dev/null +++ b/ct/opencloud.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: vhsdream +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://opencloud.eu + +APP="OpenCloud" +var_tags="${var_tags:-files;cloud}" +var_cpu="${var_cpu:-4}" +var_ram="${var_ram:-4096}" +var_disk="${var_disk:-10}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /etc/opencloud ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -s https://api.github.com/repos/opencloud-eu/opencloud/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat /etc/opencloud/version)" ]] || [[ ! -f /etc/opencloud/version ]]; then + msg_info "Stopping $APP" + systemctl stop opencloud + msg_ok "Stopped $APP" + + msg_info "Updating $APP to v${RELEASE}" + curl -fsSL "https://github.com/opencloud-eu/opencloud/releases/download/v${RELEASE}/opencloud-${RELEASE}-linux-amd64" -o /usr/bin/opencloud + chmod +x /usr/bin/opencloud + msg_ok "Updated $APP to v${RELEASE}" + + msg_info "Starting $APP" + systemctl start opencloud + msg_ok "Started $APP" + + echo "${RELEASE}" >/etc/opencloud/version + 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}https://${IP}:9200${CL}" diff --git a/install/opencloud-install.sh b/install/opencloud-install.sh new file mode 100644 index 00000000..ed85c7ab --- /dev/null +++ b/install/opencloud-install.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: vhsdream +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://opencloud.eu + +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 \ +# build-essential +# msg_ok "Installed Dependencies" + +msg_info "Installing ${APPLICATION}" +RELEASE=$(curl -s https://api.github.com/repos/opencloud-eu/opencloud/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +curl -fsSL "https://github.com/opencloud-eu/opencloud/releases/download/v${RELEASE}/opencloud-${RELEASE}-linux-amd64" -o /usr/bin/opencloud +chmod +x /usr/bin/opencloud +echo "${RELEASE}" >/etc/opencloud/version +msg_ok "Installed ${APPLICATION}" + +msg_info "Configuring ${APPLICATION}" +DATA_DIR="/var/lib/opencloud/" +CONFIG_DIR="/etc/opencloud" +ENV_FILE="${CONFIG_DIR}/opencloud.env" +IP="$(hostname -I | awk '{print $1}')" + +cat <"$ENV_FILE" +OC_URL=https://${IP}:9200 +OC_INSECURE=true +PROXY_ENABLE_BASIC_AUTH=true +IDM_CREATE_DEMO_USERS=false +OC_LOG_LEVEL=warning +OC_CONFIG_DIR=${CONFIG_DIR} +OC_BASE_DATA_PATH=${DATA_DIR} +EOF + +cat </etc/systemd/system/opencloud.service +[Unit] +Description=OpenCloud server + +[Service] +Type=simple +User=opencloud +Group=opencloud +EnvironmentFile=${ENV_FILE} +ExecStart=/usr/bin/opencloud server +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + +useradd -r -M -s /usr/sbin/nologin opencloud +chown -R opencloud:opencloud "$CONFIG_DIR" "$DATA_DIR" +sudo -u opencloud opencloud init --config-path "$CONFIG_DIR" --insecure yes +systemctl enable -q --now opencloud.service +msg_ok "Configured ${APPLICATION}" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"