From 02b6cbf3bb6f0da84122519e19ec403d722623c1 Mon Sep 17 00:00:00 2001 From: Don Locke Date: Thu, 14 Nov 2024 19:42:12 -0700 Subject: [PATCH 1/6] Add Wavelog Script --- ct/wavelog.sh | 109 +++++++++++++++++++++++++++++++++++++ install/wavelog-install.sh | 87 +++++++++++++++++++++++++++++ json/wavelog.json | 39 +++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 ct/wavelog.sh create mode 100644 install/wavelog-install.sh create mode 100644 json/wavelog.json diff --git a/ct/wavelog.sh b/ct/wavelog.sh new file mode 100644 index 00000000000..7b1ded55e1f --- /dev/null +++ b/ct/wavelog.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: Don Locke (DonLocke) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ __ __ +| | / /___ __ _____ / / ____ ____ _ +| | /| / / __ `/ | / / _ \/ / / __ \/ __ '/ +| |/ |/ / /_/ /| |/ / __/ /___/ /_/ / /_/ / +|__/|__/\__,_/ |___/\___/_____/\____/\__, / + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Wavelog" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/wavelog ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -s https://api.github.com/repos/wavelog/wavelog/releases/latest | grep "tag_name" | cut -d '"' -f 4) +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping Services" + systemctl stop apache2 + msg_ok "Services Stopped" + + msg_info "Updating ${APP} to ${RELEASE}" + cp /opt/wavelog/application/config/config.php /opt/config.php + cp /opt/wavelog/application/config/database.php /opt/database.php + cp -r /opt/wavelog/userdata /opt/userdata + if [[ -f /opt/wavelog/assets/js/sections/custom.js ]]; then + cp /opt/wavelog/assets/js/sections/custom.js /opt/custom.js + fi + wget -q "https://github.com/wavelog/wavelog/archive/refs/tags/${RELEASE}.zip" + unzip -q ${RELEASE}.zip + cp -r wavelog-${RELEASE}/* /opt/wavelog + rm -rf wavelog-${RELEASE} + rm -rf /opt/wavelog/install + mv /opt/config.php /opt/wavelog/application/config/config.php + mv /opt/database.php /opt/wavelog/application/config/database.php + cp -r /opt/userdata/* /opt/wavelog/userdata + rm -rf /opt/userdata + if [[ -f /opt/custom.js ]]; then + mv /opt/custom.js /opt/wavelog/assets/js/sections/custom.js + fi + chown -R www-data:www-data /opt/wavelog/ + find /opt/wavelog/ -type d -exec chmod 755 {} \; + find /opt/wavelog/ -type f -exec chmod 664 {} \; + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP}" + + msg_info "Starting Services" + systemctl start apache2 + msg_ok "Started Services" + + msg_info "Cleaning Up" + rm -rf ${RELEASE}.zip + msg_ok "Cleaned" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}${CL} \n" diff --git a/install/wavelog-install.sh b/install/wavelog-install.sh new file mode 100644 index 00000000000..4bead8d5c44 --- /dev/null +++ b/install/wavelog-install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: Don Locke (DonLocke) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/wavelog/wavelog + +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 \ + curl \ + libapache2-mod-php \ + mariadb-server \ + php8.2-{curl,mbstring,mysql,xml,zip} \ + unzip +msg_ok "Installed Dependencies" + +msg_info "Setting up Database" +DB_NAME=wavelog +DB_USER=waveloguser +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 "Wavelog-Credentials" + echo "Wavelog Database User: $DB_USER" + echo "Wavelog Database Password: $DB_PASS" + echo "Wavelog Database Name: $DB_NAME" +} >> ~/wavelog.creds +msg_ok "Set up database" + +msg_info "Setting up PHP" +sed -i '/max_execution_time/s/= .*/= 600/' /etc/php/8.2/apache2/php.ini +sed -i '/memory_limit/s/= .*/= 256M/' /etc/php/8.2/apache2/php.ini +sed -i '/upload_max_filesize/s/= .*/= 8M/' /etc/php/8.2/apache2/php.ini +msg_ok "Set up PHP" + +msg_info "Installing Wavelog" +RELEASE=$(curl -s https://api.github.com/repos/wavelog/wavelog/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +wget -q "https://github.com/wavelog/wavelog/archive/refs/tags/${RELEASE}.zip" +unzip -q ${RELEASE}.zip +mkdir -p /opt/wavelog +mv wavelog-${RELEASE}/* /opt/wavelog/ +rm -rf wavelog-${RELEASE} +chown -R www-data:www-data /opt/wavelog/ +find /opt/wavelog/ -type d -exec chmod 755 {} \; +find /opt/wavelog/ -type f -exec chmod 664 {} \; +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Wavelog" + +msg_info "Creating Service" +cat </etc/apache2/sites-available/wavelog.conf + + ServerAdmin webmaster@localhost + DocumentRoot /opt/wavelog + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + ErrorLog /var/log/apache2/error.log + CustomLog /var/log/apache2/access.log combined + +EOF +$STD a2ensite wavelog.conf +$STD a2dissite 000-default.conf +$STD systemctl reload apache2 +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/wavelog.json b/json/wavelog.json new file mode 100644 index 00000000000..aeba81658ac --- /dev/null +++ b/json/wavelog.json @@ -0,0 +1,39 @@ +{ + "name": "Wavelog", + "slug": "wavelog", + "categories": [ + 0 + ], + "date_created": "2024-11-12", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": "80", + "documentation": "https://github.com/wavelog/wavelog/wiki", + "website": "https://www.wavelog.org/", + "logo": "https://www.wavelog.org/wp-content/uploads/2024/04/wavelog_icon_only.png", + "description": "Wavelog is a self-hosted PHP application that allows you to log your amateur radio contacts anywhere. All you need is a web browser and active internet connection.", + "install_methods": [ + { + "type": "default", + "script": "ct/wavelog.sh", + "resources": { + "cpu": "1", + "ram": "512", + "hdd": "2", + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "Database credentials are saved in: `~/wavelog.creds`", + "type": "info" + } + ] +} \ No newline at end of file From 0bc254d3f322e8274acd27f70edbde45647913fe Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 15 Nov 2024 16:55:03 +1300 Subject: [PATCH 2/6] Added github logo which is less likely to disappear. --- json/wavelog.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json/wavelog.json b/json/wavelog.json index aeba81658ac..c07b075ab81 100644 --- a/json/wavelog.json +++ b/json/wavelog.json @@ -11,7 +11,7 @@ "interface_port": "80", "documentation": "https://github.com/wavelog/wavelog/wiki", "website": "https://www.wavelog.org/", - "logo": "https://www.wavelog.org/wp-content/uploads/2024/04/wavelog_icon_only.png", + "logo": "https://raw.githubusercontent.com/wavelog/wavelog/refs/heads/master/assets/logo/wavelog_logo_cosmo.png", "description": "Wavelog is a self-hosted PHP application that allows you to log your amateur radio contacts anywhere. All you need is a web browser and active internet connection.", "install_methods": [ { @@ -36,4 +36,4 @@ "type": "info" } ] -} \ No newline at end of file +} From b3c850ba080852e97a65b7ae80f3a33c99afdc5b Mon Sep 17 00:00:00 2001 From: Don Locke Date: Fri, 15 Nov 2024 06:58:45 -0700 Subject: [PATCH 3/6] Add Copyright, remove zip, and simplify mv in install --- ct/wavelog.sh | 2 +- install/wavelog-install.sh | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ct/wavelog.sh b/ct/wavelog.sh index 7b1ded55e1f..6bbe31669c2 100644 --- a/ct/wavelog.sh +++ b/ct/wavelog.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) -# Copyright (c) 2021-2024 tteck +# Copyright (c) 2021-2024 community-scripts ORG # Author: Don Locke (DonLocke) # License: MIT # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/install/wavelog-install.sh b/install/wavelog-install.sh index 4bead8d5c44..e093e4efc5b 100644 --- a/install/wavelog-install.sh +++ b/install/wavelog-install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2021-2024 tteck +# Copyright (c) 2021-2024 community-scripts ORG # Author: Don Locke (DonLocke) # License: MIT # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -48,9 +48,7 @@ msg_info "Installing Wavelog" RELEASE=$(curl -s https://api.github.com/repos/wavelog/wavelog/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') wget -q "https://github.com/wavelog/wavelog/archive/refs/tags/${RELEASE}.zip" unzip -q ${RELEASE}.zip -mkdir -p /opt/wavelog -mv wavelog-${RELEASE}/* /opt/wavelog/ -rm -rf wavelog-${RELEASE} +mv wavelog-${RELEASE}/ /opt/wavelog chown -R www-data:www-data /opt/wavelog/ find /opt/wavelog/ -type d -exec chmod 755 {} \; find /opt/wavelog/ -type f -exec chmod 664 {} \; @@ -82,6 +80,7 @@ motd_ssh customize msg_info "Cleaning up" +rm -f ${RELEASE}.zip $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned" From 3526bc7b00cc25da3d75f1f8aa0a7a6b89787f0e Mon Sep 17 00:00:00 2001 From: Don Locke Date: Fri, 15 Nov 2024 07:01:51 -0700 Subject: [PATCH 4/6] Update core dependecies --- install/wavelog-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/wavelog-install.sh b/install/wavelog-install.sh index e093e4efc5b..34755a2b26d 100644 --- a/install/wavelog-install.sh +++ b/install/wavelog-install.sh @@ -19,7 +19,9 @@ $STD apt-get install -y \ curl \ libapache2-mod-php \ mariadb-server \ + mc \ php8.2-{curl,mbstring,mysql,xml,zip} \ + sudo \ unzip msg_ok "Installed Dependencies" From 9fbbd9ca237b34e5d0e4b04b822757933c1b1a39 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:02:47 +0100 Subject: [PATCH 5/6] Update json/wavelog.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> --- json/wavelog.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/wavelog.json b/json/wavelog.json index c07b075ab81..3db1848bc81 100644 --- a/json/wavelog.json +++ b/json/wavelog.json @@ -32,7 +32,7 @@ }, "notes": [ { - "text": "Database credentials are saved in: `~/wavelog.creds`", + "text": "Database credentials: `cat wavelog.creds`", "type": "info" } ] From 16000d53f68e88556a40af3ccbaa09f1198ecf6a Mon Sep 17 00:00:00 2001 From: Don Locke Date: Fri, 15 Nov 2024 17:31:44 -0700 Subject: [PATCH 6/6] Remove old install during update --- ct/wavelog.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/wavelog.sh b/ct/wavelog.sh index 6bbe31669c2..d8d5afab9b8 100644 --- a/ct/wavelog.sh +++ b/ct/wavelog.sh @@ -70,8 +70,8 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v fi wget -q "https://github.com/wavelog/wavelog/archive/refs/tags/${RELEASE}.zip" unzip -q ${RELEASE}.zip - cp -r wavelog-${RELEASE}/* /opt/wavelog - rm -rf wavelog-${RELEASE} + rm -rf /opt/wavelog + mv wavelog-${RELEASE}/ /opt/wavelog rm -rf /opt/wavelog/install mv /opt/config.php /opt/wavelog/application/config/config.php mv /opt/database.php /opt/wavelog/application/config/database.php