aboutsummaryrefslogtreecommitdiff
path: root/solarc-theme-upgrade
diff options
context:
space:
mode:
authorMartin Schenck2016-08-03 17:24:19 +0200
committerMartin Schenck2016-08-03 17:24:19 +0200
commitcf773ee6b59459627c8988dd6128f7cc9a0dc23d (patch)
tree0df9fed77d3348c738abd6b610a80cf4fd293d1e /solarc-theme-upgrade
parentaa5f66d0f9b40b7ad20b4958d4dfba49fbb6d9b0 (diff)
downloadsolarc-theme-cf773ee6b59459627c8988dd6128f7cc9a0dc23d.tar.gz
solarc-theme-cf773ee6b59459627c8988dd6128f7cc9a0dc23d.tar.xz
solarc-theme-cf773ee6b59459627c8988dd6128f7cc9a0dc23d.zip
Moved arc upgrade to solarc upgrade
Fixes #6 Thanks to @tristan957
Diffstat (limited to 'solarc-theme-upgrade')
-rwxr-xr-xsolarc-theme-upgrade148
1 files changed, 148 insertions, 0 deletions
diff --git a/solarc-theme-upgrade b/solarc-theme-upgrade
new file mode 100755
index 0000000..1eae585
--- /dev/null
+++ b/solarc-theme-upgrade
@@ -0,0 +1,148 @@
+#!/bin/sh
+
+# Script to upgrade/install the solarc-theme
+
+#URL
+theme_name=solarc-theme
+
+# Theme name
+download_url=https://github.com/apheleia/$theme_name/archive/master.tar.gz
+
+# for test purporses only (the repo needs to have this script)
+# download_url=https://github.com/leoheck/$theme_name/archive/master.tar.gz
+
+# Tempdir
+tempdir=/tmp/$theme_name
+
+# Directories
+lightdir=/usr/share/themes/SolArc
+darkerdir=/usr/share/themes/SolArc-Darker
+darkdir=/usr/share/themes/SolArc-Dark
+
+userlightdir=$HOME/.themes/SolArc
+userdarkerdir=$HOME/.themes/SolArc-Darker
+userdarkdir=$HOME/.themes/SolArc-Dark
+
+userlightdir2=$HOME/local/share/themes/SolArc
+userdarkerdir2=$HOME/local/share/themes/SolArc-Darker
+userdarkdir2=$HOME/local/share/themes/SolArc-Dark
+
+#Functions
+show_error() {
+ printf "\033[1;31m$@\033[0m\n"
+}
+
+check_root() {
+ if [ "$(id -u)" -ne 0 ]; then
+ show_error "This script has to be run as root"
+ echo
+ exec sudo "$0" "$@" # Instead of exit, just re-execute as root
+ fi
+}
+
+check_command() {
+ fail=false
+
+ for i in "$@"
+ do
+ command -v $i >/dev/null 2>&1 || { show_error >&2 "This script requires "$i" but it's not installed."; fail=true; }
+ done
+
+ if [ "$fail" = true ]; then
+ echo
+ echo "Aborting."
+ echo
+ exit 1;
+ fi
+}
+
+check_directories() {
+ dirfound=false
+
+ echo "Checking if theme is installed..."
+ echo
+
+ for i in "$@"
+ do
+ if [ -d "$i" ]; then
+ echo "Found $i"
+ dirfound=true
+ fi
+ done
+
+ if [ "$dirfound" = true ]; then
+ echo
+ echo "The above directories will be overwritten."
+ fi
+
+ if [ "$dirfound" = false ]; then
+ echo "Theme is not installed."
+ fi
+}
+
+install_theme() {
+ # Clean tempdir
+ rm -rf $tempdir && mkdir $tempdir && cd $tempdir
+
+ # 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
+ make install
+
+ # Install this script
+ if [ -f $(basename $0) ]; then
+ if [ ! -f /usr/bin/$(basename $0) ]; then
+ echo
+ read -r -p "Do you like to install the $(basename $0) for future upgrades? [y/N] " response
+ case $response in
+ [yY][eE][sS]|[yY])
+ echo "Installing $(basename $0) on /usr/bin/"
+ cp -r solarc-theme-upgrade /usr/bin/
+ ;;
+ *)
+ echo "Aborted by user"
+ exit 0;
+ ;;
+ esac
+ else
+ echo "Upgrading $(basename $0)"
+ cp -f $(basename $0) /usr/bin/
+ fi
+ fi
+
+ # Remove the sources
+ rm -rf $tempdir
+
+ echo
+ echo "Installation complete."
+}
+
+# Main part
+clear
+echo '####################################'
+echo '# SolArc Theme Install Script #'
+echo '####################################'
+echo
+
+#Check available commands
+check_command automake wget pkg-config autoconf make tar
+
+#Check if we are root
+check_root
+
+#Check if theme is installed
+check_directories $lightdir $darkerdir $darkdir
+
+echo
+read -r -p "Do you want to continue installation? [y/N] " response
+case $response in
+ [yY][eE][sS]|[yY])
+ install_theme
+ ;;
+ *)
+ echo "Aborted by user"
+ exit 0;
+ ;;
+esac