diff --git a/ct/monica.sh b/ct/monica.sh index 871c95a93..35aa7c91e 100644 --- a/ct/monica.sh +++ b/ct/monica.sh @@ -27,18 +27,20 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/monicahq/monica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + if [[ ! -f ~/.monica ]] || [[ "${RELEASE}" != "$(cat ~/.monica)" ]]; then msg_info "Stopping Service" systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Updating ${APP} to v${RELEASE}" - cd /opt + msg_info "Creating backup" mv /opt/monica/ /opt/monica-backup - curl -fsSL "https://github.com/monicahq/monica/releases/download/v${RELEASE}/monica-v${RELEASE}.tar.bz2" -o $(basename "https://github.com/monicahq/monica/releases/download/v${RELEASE}/monica-v${RELEASE}.tar.bz2") - tar -xjf "monica-v${RELEASE}.tar.bz2" - mv "/opt/monica-v${RELEASE}" /opt/monica + msg_ok "Backup created" + + fetch_and_deploy_gh_release "monica" "monicahq/monica" "prebuild" "latest" "/opt/monica" "monica-v*.tar.bz2" + + msg_info "Configuring monica" cd /opt/monica/ cp -r /opt/monica-backup/.env /opt/monica cp -r /opt/monica-backup/storage/* /opt/monica/storage/ @@ -48,17 +50,16 @@ function update_script() { $STD php artisan monica:update --force chown -R www-data:www-data /opt/monica chmod -R 775 /opt/monica/storage - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to v${RELEASE}" + msg_ok "Configured monica" msg_info "Starting Service" systemctl start apache2 msg_ok "Started Service" msg_info "Cleaning up" - rm -r "/opt/monica-v${RELEASE}.tar.bz2" rm -r /opt/monica-backup msg_ok "Cleaned" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/install/monica-install.sh b/install/monica-install.sh index 1f9ab9154..41a00d5da 100644 --- a/install/monica-install.sh +++ b/install/monica-install.sh @@ -13,14 +13,8 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" -$STD apt-get install -y \ - apache2 \ - libapache2-mod-php \ - php-{bcmath,curl,dom,gd,gmp,iconv,intl,json,mbstring,mysqli,opcache,pdo-mysql,redis,tokenizer,xml,zip} \ - composer -msg_ok "Installed Dependencies" - +PHP_VERSION="8.2" PHP_APACHE="YES" PHP_MODULE="dom,gmp,iconv,mysqli,pdo-mysql,redis,tokenizer" setup_php +setup_composer setup_mariadb NODE_VERSION="20" NODE_MODULE="yarn@latest" setup_nodejs @@ -39,12 +33,9 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS } >>~/monica.creds msg_ok "Set up MariaDB" -msg_info "Installing monica" -RELEASE=$(curl -fsSL https://api.github.com/repos/monicahq/monica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -cd /opt -curl -fsSL "https://github.com/monicahq/monica/releases/download/v${RELEASE}/monica-v${RELEASE}.tar.bz2" -o "monica-v${RELEASE}.tar.bz2" -tar -xjf "monica-v${RELEASE}.tar.bz2" -mv "/opt/monica-v${RELEASE}" /opt/monica +fetch_and_deploy_gh_release "monica" "monicahq/monica" "prebuild" "latest" "/opt/monica" "monica-v*.tar.bz2" + +msg_info "Configuring monica" cd /opt/monica cp /opt/monica/.env.example /opt/monica/.env HASH_SALT=$(openssl rand -base64 32) @@ -59,8 +50,7 @@ $STD php artisan key:generate $STD php artisan setup:production --email=admin@helper-scripts.com --password=helper-scripts.com --force chown -R www-data:www-data /opt/monica chmod -R 775 /opt/monica/storage -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed monica" +msg_ok "Configured monica" msg_info "Creating Service" cat </etc/apache2/sites-available/monica.conf @@ -87,7 +77,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf "/opt/monica-v${RELEASE}.tar.bz2" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"