This commit is contained in:
Slaviša Arežina 2025-07-31 14:00:57 +02:00 committed by GitHub
parent b5b59342bd
commit 492be65aec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 26 deletions

View File

@ -27,18 +27,20 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/monicahq/monica/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') 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" msg_info "Stopping Service"
systemctl stop apache2 systemctl stop apache2
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Updating ${APP} to v${RELEASE}" msg_info "Creating backup"
cd /opt
mv /opt/monica/ /opt/monica-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") msg_ok "Backup created"
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/ cd /opt/monica/
cp -r /opt/monica-backup/.env /opt/monica cp -r /opt/monica-backup/.env /opt/monica
cp -r /opt/monica-backup/storage/* /opt/monica/storage/ cp -r /opt/monica-backup/storage/* /opt/monica/storage/
@ -48,17 +50,16 @@ function update_script() {
$STD php artisan monica:update --force $STD php artisan monica:update --force
chown -R www-data:www-data /opt/monica chown -R www-data:www-data /opt/monica
chmod -R 775 /opt/monica/storage chmod -R 775 /opt/monica/storage
echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Configured monica"
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start apache2 systemctl start apache2
msg_ok "Started Service" msg_ok "Started Service"
msg_info "Cleaning up" msg_info "Cleaning up"
rm -r "/opt/monica-v${RELEASE}.tar.bz2"
rm -r /opt/monica-backup rm -r /opt/monica-backup
msg_ok "Cleaned" msg_ok "Cleaned"
msg_ok "Updated Successfully" msg_ok "Updated Successfully"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "No update required. ${APP} is already at v${RELEASE}"

View File

@ -13,14 +13,8 @@ setting_up_container
network_check network_check
update_os update_os
msg_info "Installing Dependencies" PHP_VERSION="8.2" PHP_APACHE="YES" PHP_MODULE="dom,gmp,iconv,mysqli,pdo-mysql,redis,tokenizer" setup_php
$STD apt-get install -y \ setup_composer
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"
setup_mariadb setup_mariadb
NODE_VERSION="20" NODE_MODULE="yarn@latest" setup_nodejs 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 } >>~/monica.creds
msg_ok "Set up MariaDB" msg_ok "Set up MariaDB"
msg_info "Installing monica" fetch_and_deploy_gh_release "monica" "monicahq/monica" "prebuild" "latest" "/opt/monica" "monica-v*.tar.bz2"
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 msg_info "Configuring monica"
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
cd /opt/monica cd /opt/monica
cp /opt/monica/.env.example /opt/monica/.env cp /opt/monica/.env.example /opt/monica/.env
HASH_SALT=$(openssl rand -base64 32) 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 $STD php artisan setup:production --email=admin@helper-scripts.com --password=helper-scripts.com --force
chown -R www-data:www-data /opt/monica chown -R www-data:www-data /opt/monica
chmod -R 775 /opt/monica/storage chmod -R 775 /opt/monica/storage
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Configured monica"
msg_ok "Installed monica"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/apache2/sites-available/monica.conf cat <<EOF >/etc/apache2/sites-available/monica.conf
@ -87,7 +77,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf "/opt/monica-v${RELEASE}.tar.bz2"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"