Refactor (#7095)
This commit is contained in:
parent
c207d65b1b
commit
e72f248918
@ -27,29 +27,25 @@ 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/phpipam/phpipam/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
RELEASE=$(curl -fsSL https://api.github.com/repos/phpipam/phpipam/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 ~/.phpipam ]] || [[ "${RELEASE}" != "$(cat ~/.phpipam 2>/dev/null)" ]]; 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}"
|
|
||||||
cd /opt
|
|
||||||
mv /opt/phpipam/ /opt/phpipam-backup
|
mv /opt/phpipam/ /opt/phpipam-backup
|
||||||
curl -fsSL "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip" -o $(basename "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip")
|
fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip"
|
||||||
$STD unzip "phpipam-v${RELEASE}.zip"
|
|
||||||
cp /opt/phpipam-backup/config.php /opt/phpipam
|
cp /opt/phpipam-backup/config.php /opt/phpipam
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
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/phpipam-v${RELEASE}.zip"
|
|
||||||
rm -r /opt/phpipam-backup
|
rm -r /opt/phpipam-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}"
|
||||||
|
@ -14,13 +14,10 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt-get install -y \
|
$STD apt-get install -y php-pear
|
||||||
apache2 \
|
|
||||||
libapache2-mod-php \
|
|
||||||
php8.2 php8.2-{fpm,curl,cli,mysql,gd,intl,imap,apcu,pspell,tidy,xmlrpc,mbstring,gmp,xml,ldap,common,snmp} \
|
|
||||||
php-pear
|
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
PHP_VERSION="8.2" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="mysql,imap,apcu,pspell,tidy,xmlrpc,gmp,ldap,common,snmp" setup_php
|
||||||
setup_mariadb
|
setup_mariadb
|
||||||
|
|
||||||
msg_info "Setting up MariaDB"
|
msg_info "Setting up MariaDB"
|
||||||
@ -38,11 +35,9 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS
|
|||||||
} >>~/phpipam.creds
|
} >>~/phpipam.creds
|
||||||
msg_ok "Set up MariaDB"
|
msg_ok "Set up MariaDB"
|
||||||
|
|
||||||
|
fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip"
|
||||||
|
|
||||||
msg_info "Installing phpIPAM"
|
msg_info "Installing phpIPAM"
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/phpipam/phpipam/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
|
||||||
cd /opt
|
|
||||||
curl -fsSL "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip" -o "phpipam-v${RELEASE}.zip"
|
|
||||||
$STD unzip "phpipam-v${RELEASE}.zip"
|
|
||||||
$STD mariadb -u root "${DB_NAME}" </opt/phpipam/db/SCHEMA.sql
|
$STD mariadb -u root "${DB_NAME}" </opt/phpipam/db/SCHEMA.sql
|
||||||
cp /opt/phpipam/config.dist.php /opt/phpipam/config.php
|
cp /opt/phpipam/config.dist.php /opt/phpipam/config.php
|
||||||
sed -i -e "s/\(\$disable_installer = \).*/\1true;/" \
|
sed -i -e "s/\(\$disable_installer = \).*/\1true;/" \
|
||||||
@ -51,7 +46,6 @@ sed -i -e "s/\(\$disable_installer = \).*/\1true;/" \
|
|||||||
-e "s/\(\$db\['name'\] = \).*/\1'$DB_NAME';/" \
|
-e "s/\(\$db\['name'\] = \).*/\1'$DB_NAME';/" \
|
||||||
/opt/phpipam/config.php
|
/opt/phpipam/config.php
|
||||||
sed -i '/max_execution_time/s/= .*/= 600/' /etc/php/8.2/apache2/php.ini
|
sed -i '/max_execution_time/s/= .*/= 600/' /etc/php/8.2/apache2/php.ini
|
||||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
|
||||||
msg_ok "Installed phpIPAM"
|
msg_ok "Installed phpIPAM"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
@ -79,7 +73,6 @@ motd_ssh
|
|||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
rm -rf "/opt/phpipam-v${RELEASE}.zip"
|
|
||||||
$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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user