Stash all changed files, clean directory and pull updates.

pull/890/head
Dan Schaper 8 years ago
parent dfb4ac0365
commit 1d64ad1ccd

@ -28,8 +28,8 @@ is_repo() {
prep_dirs() { prep_dirs() {
# Prepare directory for local repository building # Prepare directory for local repository building
local dir_to_clean="${1}" local directory="${1}"
rm -rf "${dir_to_clean}" &> /dev/null rm -rf "${directory}" &> /dev/null
return return
} }
@ -48,9 +48,13 @@ update_repo() {
local dest_dir="${1}" local dest_dir="${1}"
# Pull the latest commits # Pull the latest commits
echo -n "::: Updating repository in ${dest_dir}..." echo -n "::: Updating repository in ${dest_dir}..."
cd "${1}" || exit 1
git stash -q > /dev/null || exit $? # Stash all files not tracked for later retrieval
git pull -q > /dev/null || exit $? git -C "${dest_dir}" stash --all --quiet &> /dev/null || false
# Force a clean working directory for cloning
git -C "${dest_dir}" clean --force -d &> /dev/null || false
# Fetch latest changes and apply
git -C "${dest_dir}" pull --quiet &> /dev/null || false
echo " done!" echo " done!"
} }
@ -62,7 +66,7 @@ getGitFiles() {
echo ":::" echo ":::"
echo "::: Checking for existing repository..." echo "::: Checking for existing repository..."
if is_repo "${directory}"; then if is_repo "${directory}"; then
update_repo "${directory}" update_repo "${directory}" || (echo "*** Error: Could not update local repository. Contact support."; exit 1)
else else
make_repo "${directory}" "${remoteRepo}" make_repo "${directory}" "${remoteRepo}"
fi fi

@ -10,6 +10,7 @@
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
PI_HOLE_SCRIPT_DIR="/opt/pihole"
# Must be root to use this tool # Must be root to use this tool
if [[ ! $EUID -eq 0 ]];then if [[ ! $EUID -eq 0 ]];then
if [ -x "$(command -v sudo)" ];then if [ -x "$(command -v sudo)" ];then
@ -22,27 +23,27 @@ if [[ ! $EUID -eq 0 ]];then
fi fi
whitelistFunc() { whitelistFunc() {
/opt/pihole/list.sh "$@" "${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
exit 0 exit 0
} }
blacklistFunc() { blacklistFunc() {
/opt/pihole/list.sh "$@" "${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
exit 0 exit 0
} }
debugFunc() { debugFunc() {
/opt/pihole/piholeDebug.sh "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh
exit 0 exit 0
} }
flushFunc() { flushFunc() {
/opt/pihole/piholeLogFlush.sh "${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh
exit 0 exit 0
} }
updatePiholeFunc() { updatePiholeFunc() {
/opt/pihole/update.sh "${PI_HOLE_SCRIPT_DIR}"/update.sh
exit 0 exit 0
} }
@ -52,12 +53,12 @@ reconfigurePiholeFunc() {
} }
updateGravityFunc() { updateGravityFunc() {
/opt/pihole/gravity.sh "$@" "${PI_HOLE_SCRIPT_DIR}"/gravity.sh "$@"
exit 0 exit 0
} }
setupLCDFunction() { setupLCDFunction() {
/opt/pihole/setupLCD.sh "${PI_HOLE_SCRIPT_DIR}"/setupLCD.sh
exit 0 exit 0
} }
@ -76,19 +77,19 @@ queryFunc() {
chronometerFunc() { chronometerFunc() {
shift shift
/opt/pihole/chronometer.sh "$@" "${PI_HOLE_SCRIPT_DIR}"/chronometer.sh "$@"
exit 0 exit 0
} }
uninstallFunc() { uninstallFunc() {
/opt/pihole/uninstall.sh "${PI_HOLE_SCRIPT_DIR}"/uninstall.sh
exit 0 exit 0
} }
versionFunc() { versionFunc() {
shift shift
/opt/pihole/version.sh "$@" "${PI_HOLE_SCRIPT_DIR}"/version.sh "$@"
exit 0 exit 0
} }

Loading…
Cancel
Save