Skip to content

Commit

Permalink
1. Re-execute as root, 2. Fail safe remove dirs
Browse files Browse the repository at this point in the history
1. When not root, automatically re-execute as root instead of exit 1
2. Perform `rm -rf $lightdir $darkerdir $darkdir` only after download of package and extraction completes without error.
  • Loading branch information
majal committed Dec 5, 2015
1 parent d5d7a1c commit ed307d6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions arc-theme-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ echo -e "\033[1;31m$@\033[0m"
check_root() {
if [[ "${EUID}" -ne 0 ]]; then
show_error "This script has to be run as root"
exit 1;
echo
exec sudo "$0" "$@" # Instead of exit, just re-execute as root
fi
}

Expand Down Expand Up @@ -80,15 +81,11 @@ check_directories() {
}

install_theme() {
# Remove current installation
rm -rf $lightdir $darkerdir $darkdir

# Clean tempdir
rm -rf $tempdir && mkdir $tempdir && cd $tempdir

# Get the sources
wget $download_url
tar xf master.tar.gz && cd "$theme_name"-master
# Get the sources && Remove current installation only if download and unpack are successful
wget $download_url && tar xf master.tar.gz && rm -rf $lightdir $darkerdir $darkdir && cd "$theme_name"-master

# Build and install
./autogen.sh --prefix=/usr
Expand Down

0 comments on commit ed307d6

Please sign in to comment.