From 0271e704a8f638fca482dfe97bc2e1f4c5ba91ef Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:27:00 +0200 Subject: [PATCH] hortus test --- ct/hortusfox.sh | 65 +++++++++++++++++++++++++++ install/hortusfox-install.sh | 86 ++++++++++++++++++++++++++++++++++++ tools/pve/clean-lxcs.sh | 3 +- 3 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 ct/hortusfox.sh create mode 100644 install/hortusfox-install.sh diff --git a/ct/hortusfox.sh b/ct/hortusfox.sh new file mode 100644 index 00000000..63ea9db3 --- /dev/null +++ b/ct/hortusfox.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +source <(curl -s https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: bvdberg01 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/manyfold3d/manyfold + +APP="HortusFox" +var_tags="${var_tags:-network}" +var_cpu="${var_cpu:-4}" +var_ram="${var_ram:-4096}" +var_disk="${var_disk:-15}" +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 /opt/hortusfox ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/danielbrendel/hortusfox-web/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping Service" + systemctl stop apache2 + msg_ok "Stopped Service" + + msg_info "Updating ${APP} to v${RELEASE}" + cd /opt + mv /opt/hortusfox/ /opt/hortusfox-backup + + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to v${RELEASE}" + + msg_info "Starting Service" + systemctl start service + msg_ok "Started Service" + + msg_info "Cleaning up" + rm -r "/opt/${RELEASE}.zip" + rm -r /opt/hortusfox-backup + msg_ok "Cleaned" + msg_ok "Updated Successfully" + 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}${CL}" diff --git a/install/hortusfox-install.sh b/install/hortusfox-install.sh new file mode 100644 index 00000000..49c78c5b --- /dev/null +++ b/install/hortusfox-install.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/danielbrendel/hortusfox-web + +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 apache2 +msg_ok "Installed Dependencies" + +PHP_MODULE="exif,pcntl,mysql" PHP_APACHE="YES" PHP_FPM="NO" PHP_VERSION="8.3" setup_php +setup_mariadb +setup_composer + +msg_info "Setting up database" +DB_NAME=hortusfox +DB_USER=hortusfox +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" +$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" +$STD mariadb -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +{ + echo "HortusFox Database Credentials" + echo "Database: $DB_NAME" + echo "Username: $DB_USER" + echo "Password: $DB_PASS" +} >>~/hortusfox.creds +msg_ok "Set up database" + +fetch_and_deploy_gh_release "hortusfox-web" "danielbrendel/hortusfox-web" + +msg_info "Configuring .env" +cp /opt/hortusfox-web/.env.example /opt/hortusfox-web/.env +sed -i "s|^DB_HOST=.*|DB_HOST=localhost|" /opt/hortusfox-web/.env +sed -i "s|^DB_USER=.*|DB_USER=$DB_USER|" /opt/hortusfox-web/.env +sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" /opt/hortusfox-web/.env +sed -i "s|^DB_DATABASE=.*|DB_DATABASE=$DB_NAME|" /opt/hortusfox-web/.env +sed -i "s|^DB_ENABLE=.*|DB_ENABLE=true|" /opt/hortusfox-web/.env +sed -i "s|^APP_TIMEZONE=.*|APP_TIMEZONE=Europe/Berlin|" /opt/hortusfox-web/.env +msg_ok ".env configured" + +msg_info "Installing PHP dependencies (composer)" +cd /opt/hortusfox-web +$STD composer install --no-dev --optimize-autoloader +msg_ok "PHP dependencies installed" + +msg_info "Running DB migration" +php asatru migrate:fresh +msg_ok "Migration finished" + +msg_info "Configuring Apache vHost" +cat </etc/apache2/sites-available/hortusfox.conf + + ServerAdmin webmaster@localhost + DocumentRoot /opt/hortusfox-web/public + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + ErrorLog \${APACHE_LOG_DIR}/hortusfox_error.log + CustomLog \${APACHE_LOG_DIR}/hortusfox_access.log combined + +EOF +$STD a2dissite 000-default +$STD a2ensite hortusfox +$STD a2enmod rewrite +systemctl restart apache2 +msg_ok "Apache configured" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/tools/pve/clean-lxcs.sh b/tools/pve/clean-lxcs.sh index 4edb7b6c..dc96eaa8 100644 --- a/tools/pve/clean-lxcs.sh +++ b/tools/pve/clean-lxcs.sh @@ -49,10 +49,11 @@ function clean_container() { os=$(pct config "$container" | awk '/^ostype/ {print $2}') echo -e "${BL}[Info]${GN} Cleaning ${name} (${os}) ${CL} \n" if [ "$os" = "alpine" ]; then - pct exec "$container" -- ash -c "apk update && apk cache clean && rm -rf /var/cache/apk/*" + pct exec "$container" -- ash -c "wget -qO- https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/tools/pve/clean.sh | ash" else pct exec "$container" -- bash -c "apt-get -y --purge autoremove && apt-get -y autoclean && bash <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/tools/pve/clean.sh) && rm -rf /var/lib/apt/lists/* && apt-get update" fi + } for container in $(pct list | awk 'NR>1 {print $1}'); do