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!"
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}"

View File

@ -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 <<EOF >/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"