Replace mv source > dest with rsync, preserving sys_read_logfile.php

This commit is contained in:
billz 2023-11-22 19:00:32 +00:00
parent e55f4e2395
commit 90456e601e

View file

@ -546,17 +546,18 @@ function _create_openvpn_scripts() {
# Fetches latest files from github to webroot
function _download_latest_files() {
_install_log "Cloning latest files from GitHub"
source_dir="/tmp/raspap-webgui"
if [ "$repo" == "RaspAP/raspap-insiders" ]; then
if [ -n "$username" ] && [ -n "$acctoken" ]; then
insiders_source_url="https://${username}:${acctoken}@github.com/$repo"
git clone --branch $branch --depth 1 -c advice.detachedHead=false $insiders_source_url /tmp/raspap-webgui || clone=false
git clone --branch $branch --depth 1 -c advice.detachedHead=false $insiders_source_url $source_dir || clone=false
else
_install_status 3
echo "Insiders please read this: https://docs.raspap.com/insiders/#authentication"
fi
fi
if [ -z "$insiders_source_url" ]; then
git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url /tmp/raspap-webgui || clone=false
git clone --branch $branch --depth 1 -c advice.detachedHead=false $git_source_url $source_dir || clone=false
fi
if [ "$clone" = false ]; then
_install_status 1 "Unable to download files from github"
@ -565,13 +566,14 @@ function _download_latest_files() {
fi
if [ -d "$webroot_dir" ] && [ "$update" == 0 ]; then
sudo mv $webroot_dir "$webroot_dir.`date +%F-%R`" || _install_status 1 "Unable to remove old webroot directory"
sudo mv $webroot_dir "$webroot_dir.`date +%F-%R`" || _install_status 1 "Unable to move existing webroot directory"
elif [ "$upgrade" == 1 ] || [ "$update" == 1 ]; then
sudo rm -rf "$webroot_dir"
shopt -s extglob
sudo find "$webroot_dir" ! -path "${webroot_dir}/ajax/system/sys_read_logfile.php" -delete 2>/dev/null
fi
_install_log "Installing application to $webroot_dir"
sudo mv /tmp/raspap-webgui $webroot_dir || _install_status 1 "Unable to move raspap-webgui to $webroot_dir"
sudo rsync -av --exclude='/ajax/system/sys_read_logfile.php' "$source_dir"/ "$webroot_dir"/ >/dev/null 2>&1 || _install_status 1 "Unable to install files to $webroot_dir"
if [ "$update" == 1 ]; then
_install_log "Applying existing configuration to ${webroot_dir}/includes"
@ -582,11 +584,13 @@ function _download_latest_files() {
sudo mv /tmp/raspap.auth $raspap_dir || _install_status 1 "Unable to restore authentification credentials file to ${raspap_dir}"
fi
else
echo "Copying primary RaspAP config to includes/config.php"
echo "Copying primary RaspAP config to ${webroot_dir}/includes/config.php"
if [ ! -f "$webroot_dir/includes/config.php" ]; then
sudo cp "$webroot_dir/config/config.php" "$webroot_dir/includes/config.php"
fi
fi
echo "Removing source files at ${source_dir}"
sudo rm -rf $source_dir
_install_status 0
}