1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Backup/apply auth + config with --upgrade. Related to #1162

This commit is contained in:
billz 2022-06-05 13:42:00 +01:00
parent 41cff23878
commit 9d5088adf0

View File

@ -43,8 +43,8 @@ function _install_raspap() {
_update_system_packages _update_system_packages
_install_dependencies _install_dependencies
_enable_php_lighttpd _enable_php_lighttpd
_check_for_old_configs
_create_raspap_directories _create_raspap_directories
_check_for_old_configs
_optimize_php _optimize_php
_download_latest_files _download_latest_files
_change_file_ownership _change_file_ownership
@ -184,6 +184,13 @@ function _enable_php_lighttpd() {
# Verifies existence and permissions of RaspAP directory # Verifies existence and permissions of RaspAP directory
function _create_raspap_directories() { function _create_raspap_directories() {
if [ "$upgrade" == 1 ]; then
if [ -f $raspap_dir/raspap.auth ]; then
_install_log "Moving existing raspap.auth file to /tmp"
sudo mv $raspap_dir/raspap.auth /tmp || _install_status 1 "Unable to backup raspap.auth to /tmp"
fi
fi
_install_log "Creating RaspAP directories" _install_log "Creating RaspAP directories"
if [ -d "$raspap_dir" ]; then if [ -d "$raspap_dir" ]; then
sudo mv $raspap_dir "$raspap_dir.`date +%F-%R`" || _install_status 1 "Unable to move old '$raspap_dir' out of the way" sudo mv $raspap_dir "$raspap_dir.`date +%F-%R`" || _install_status 1 "Unable to move old '$raspap_dir' out of the way"
@ -267,7 +274,6 @@ function _install_lighttpd_configs() {
_install_status 0 _install_status 0
} }
# Prompt to install ad blocking # Prompt to install ad blocking
function _prompt_install_adblock() { function _prompt_install_adblock() {
_install_log "Configure ad blocking (Beta)" _install_log "Configure ad blocking (Beta)"
@ -275,7 +281,7 @@ function _prompt_install_adblock() {
if [ "$assume_yes" == 0 ]; then if [ "$assume_yes" == 0 ]; then
read answer < /dev/tty read answer < /dev/tty
if [ "$answer" != "${answer#[Nn]}" ]; then if [ "$answer" != "${answer#[Nn]}" ]; then
echo -e _install_status 0 "(Skipped)"
else else
_install_adblock _install_adblock
fi fi
@ -339,7 +345,7 @@ function _prompt_install_openvpn() {
if [ "$assume_yes" == 0 ]; then if [ "$assume_yes" == 0 ]; then
read answer < /dev/tty read answer < /dev/tty
if [ "$answer" != "${answer#[Nn]}" ]; then if [ "$answer" != "${answer#[Nn]}" ]; then
echo -e _install_status 0 "(Skipped)"
else else
_install_openvpn _install_openvpn
fi fi
@ -357,7 +363,7 @@ function _prompt_install_wireguard() {
if [ "$assume_yes" == 0 ]; then if [ "$assume_yes" == 0 ]; then
read answer < /dev/tty read answer < /dev/tty
if [ "$answer" != "${answer#[Nn]}" ]; then if [ "$answer" != "${answer#[Nn]}" ]; then
echo -e _install_status 0 "(Skipped)"
else else
_install_wireguard _install_wireguard
fi fi
@ -420,13 +426,14 @@ function _download_latest_files() {
_install_log "Cloning latest files from github" _install_log "Cloning latest files from github"
git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url /tmp/raspap-webgui || _install_status 1 "Unable to download files from github" git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url /tmp/raspap-webgui || _install_status 1 "Unable to download files from github"
sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to web root" sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to web root"
if [ "$upgrade" == 1 ]; then if [ "$upgrade" == 1 ]; then
_install_log "Applying existing configuration to ${webroot_dir}/includes" _install_log "Applying existing configuration to ${webroot_dir}/includes"
sudo mv /tmp/config.php $webroot_dir/includes || _install_status 1 "Unable to move config.php to ${webroot_dir}/includes" sudo mv /tmp/config.php $webroot_dir/includes || _install_status 1 "Unable to move config.php to ${webroot_dir}/includes"
if [ -f /tmp/raspap.auth ]; then if [ -f /tmp/raspap.auth ]; then
_install_log "Applying existing authentication file to ${raspap_dir}"
sudo mv /tmp/raspap.auth $raspap_dir || _install_status 1 "Unable to restore authentification credentials file to ${raspap_dir}" sudo mv /tmp/raspap.auth $raspap_dir || _install_status 1 "Unable to restore authentification credentials file to ${raspap_dir}"
fi fi
fi fi
@ -449,10 +456,6 @@ function _check_for_old_configs() {
if [ "$upgrade" == 1 ]; then if [ "$upgrade" == 1 ]; then
_install_log "Moving existing configuration to /tmp" _install_log "Moving existing configuration to /tmp"
sudo mv $webroot_dir/includes/config.php /tmp || _install_status 1 "Unable to move config.php to /tmp" sudo mv $webroot_dir/includes/config.php /tmp || _install_status 1 "Unable to move config.php to /tmp"
if [ -f $raspap_dir/raspap.auth ]; then
sudo mv $raspap_dir/raspap.auth /tmp || _install_status 1 "Unable to backup raspap.auth to /tmp"
fi
else else
_install_log "Backing up existing configs to ${raspap_dir}/backups" _install_log "Backing up existing configs to ${raspap_dir}/backups"
if [ -f /etc/network/interfaces ]; then if [ -f /etc/network/interfaces ]; then
@ -577,7 +580,7 @@ function _configure_networking() {
if [ "$assume_yes" == 0 ]; then if [ "$assume_yes" == 0 ]; then
read answer < /dev/tty read answer < /dev/tty
if [ "$answer" != "${answer#[Nn]}" ]; then if [ "$answer" != "${answer#[Nn]}" ]; then
echo -e _install_status 0 "(Skipped)"
else else
_enable_raspap_daemon _enable_raspap_daemon
fi fi