aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorziggys <ziggys@autistici.org>2018-07-21 16:56:20 -0400
committerziggys <ziggys@autistici.org>2018-07-21 16:56:20 -0400
commit770bfad1aac0bc6390ceb2d5aec38ead19fda1df (patch)
tree189b97e401c99cc7addb8ca92f40c35aebee3dbd
parentc915a7ad38ab86f2ae08bc8a2535be81aaf8aa25 (diff)
downloadgsocial-cli-770bfad1aac0bc6390ceb2d5aec38ead19fda1df.tar
gsocial-cli-770bfad1aac0bc6390ceb2d5aec38ead19fda1df.zip
Add installer script
A script to install/uninstall/upgrade gsocial-cli systemwide
-rwxr-xr-xgsocial-cli.sh3
-rwxr-xr-xscripts/installer.sh (renamed from scripts/install.sh)72
-rw-r--r--themes/default.theme2
-rw-r--r--themes/greyscale.theme2
4 files changed, 70 insertions, 9 deletions
diff --git a/gsocial-cli.sh b/gsocial-cli.sh
index e1fa857..f971018 100755
--- a/gsocial-cli.sh
+++ b/gsocial-cli.sh
@@ -500,7 +500,8 @@ ACCT="$(mktemp -p "${TMPDIR}")"
THFT="$(mktemp -p "${TMPDIR}")"
CURLOUT="$(mktemp -p "${TMPDIR}")"
DN="/dev/null"
-CONFIGD="${XDG_HOME_CONFIG:=${HOME}/.config/${SCRIPTNAME}}"
+XDGCONFIG="${XDG_HOME_CONFIG:=${HOME}/.config}"
+CONFIGD="${XDGCONFIG}/${SCRIPTNAME}"
GSF="${CONFIGD}/${SCRIPTNAME}_config"
test ! -d "${CONFIGD}" && mkdir -p "${CONFIGD}"
diff --git a/scripts/install.sh b/scripts/installer.sh
index d345d3d..16c1030 100755
--- a/scripts/install.sh
+++ b/scripts/installer.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# gsocial-cli -- install.sh
-# A simple script to install/uninstall gsocial-cli systemwide
+# gsocial-cli -- installer.sh
+# A simple script to install/uninstall/upgrade gsocial-cli systemwide
# This script is part of the gsocial-cli project
# Author: ziggys
# License: The Drunken BEER License v 1.1 (https://git.p4g.club/git/beer/about)
@@ -29,6 +29,7 @@ Usage: ${SCRIPTNAME} [option] <args>
Options
-p, --prefix <PATH> Install gsocial-cli in PATH (e.g. '/usr/bin/')
-u, --uninstall Uninstall gsocial-cli from where it's installed
+ -U, --upgrade Upgrade gsocial-cli current version
-h HELP Print this help and exit
@@ -49,23 +50,37 @@ exit 0
install () {
PWD="$(pwd)"
PPWD="${PWD%%/scripts}"
- ISX="$(find "${PSCRIPT}" -perm /a=x)"
test "${PPWD}" != "${PWD}" && cd ..
+ ISX="$(find "${PSCRIPT}" -perm /a=x)"
test -z "${ISX}" && chmod +x "${PSCRIPT}"
- cp "${PSCRIPT}" "${PREFIX}${PSCRIPT%%.sh}"
+ sudo cp "${PSCRIPT}" "${PREFIX}${PSCRIPT%%.sh}"
WHERE="$(which gsocial-cli)"
test ! -z "${WHERE}" && printf "\\e%sDone!\\n" "${good_c}"
exit 0
}
-# install
+# uninstall
uninstall () {
- test -f "${PREFIX}" && rm -f "${PREFIX}"
+ test -f "${PREFIX}" && sudo rm -f "${PREFIX}"
WHERE="$(which gsocial-cli)"
test -z "${WHERE}" && printf "\\e%sDone!\\n" "${good_c}"
exit 0
}
+# upgrade
+upgrade () {
+ # reset configuration
+ PPSCRIPT="${PSCRIPT%%.sh}"
+ XDGCONFIG="${XDG_HOME_CONFIG:=${HOME}/.config}"
+ CONFIGD="${XDGCONFIG}/${PPSCRIPT}"
+ GSF="${CONFIGD}/${PPSCRIPT}_config"
+ rm -f "${CONFIGD}"/*.history
+ rm -f "${CONFIGD}"/*.theme
+ rm -f "${GSF}"
+ rm -f "${PREFIX}"
+ install
+}
+
# colors for stdout
good_c="[0;32m"
warn_c="[0;33m"
@@ -86,6 +101,7 @@ case "${ACTION}" in
"${good_c}" "${PSCRIPT%%.sh}" "${good_c}" "${PREFIX}"
install
;;
+
"-u" | "--uninstall" )
PREFIX="$(which gsocial-cli)"
printf "\\e%sgsocial-cli-%s\\e[0m v%s\\n\\n" \
@@ -100,6 +116,50 @@ case "${ACTION}" in
"${good_c}" "${PSCRIPT%%.sh}" "${good_c}" "${PREFIX}"
uninstall
;;
+
+ "-U" | "--upgrade" )
+ printf "\\e%sgsocial-cli-%s\\e[0m v%s\\n\\n" \
+ "${good_c}" "${SCRIPTNAME}" "${VERSION}"
+
+ WHEREIS="$(which gsocial-cli)"
+
+
+ if [ -z "${WHEREIS}" ]; then
+ printf "\\e%sfatal: \\e%s%s\\e%s is not installed\\e[0m\\n" \
+ "${diee_c}" "${warn_c}" "${PSCRIPT%%.sh}" "${info_c}"
+ printf "\\e%sInstalling now...\\e[0m\\n" "${warn_c}"
+ PREFIX="/usr/bin/"
+ install
+
+ else
+ NEXT="${VERSION}"
+ CURRENT="$("${WHEREIS}" | grep "version" | awk '{print $3}')"
+
+ test "${CURRENT}" = "${NEXT}" \
+ && printf "\\e%s%s\\e[0m is already in its last version\\n\\n" \
+ "${good_c}" "${PSCRIPT%%.sh}" \
+ && exit 0
+
+ printf "Upgrading \\e%s%s\\e[0m \\e%sv.%s\\e[0m to \\e%sv.%s\\e[0m\\n" \
+ "${good_c}" "${PSCRIPT}" "${good_c}" "${CURRENT}" "${warn_c}" "${NEXT}"
+ printf "\\e%sWARNING:\\e[0mThis action will " "${warn_c}"
+ printf "\\e%sRESET\\e[0m global settings " "${warn_c}"
+ printf "and \\e%sERASE\\e[0m all history files.\\n" "${warn_c}"
+ printf "\\e%sPlease,\\e[0m do a backup before\\n\\n" "${warn_c}"
+ printf "\\e%sPROFILES\\e[0m will be kept safely untouched\\n" "${good_c}"
+ printf "Do you wish to continue? (yes/no): "
+ read -r UPGRADEME
+ fi
+
+ case "${UPGRADEME}" in
+ yes | YES | y | Y | Yes ) upgrade ;;
+ no | NO | n | N | No ) printf "\\e%sexiting now..\\e[0m\\n\\n" \
+ "${diee_c}" ;;
+ *) printf "\\e%sinvalid: \\e%s%s\\e[0m\\n\\n" \
+ "${diee_c}" "${info_c}" "${UPGRADEME}" ;;
+ esac
+ ;;
+
"-h" | "--help" ) usage "$@" ;;
esac
diff --git a/themes/default.theme b/themes/default.theme
index ca6b0e5..13c84a9 100644
--- a/themes/default.theme
+++ b/themes/default.theme
@@ -17,4 +17,4 @@ uname_c=0;37m
sid_c=0;33m
text_c=0;37m
meta_c=0;36m
-esq_seq=0m
+myself_c=0;35m
diff --git a/themes/greyscale.theme b/themes/greyscale.theme
index 8e276bd..f9a279c 100644
--- a/themes/greyscale.theme
+++ b/themes/greyscale.theme
@@ -17,4 +17,4 @@ uname_c=0;37m
sid_c=1;30m
text_c=0;37m
meta_c=1;37m
-esq_seq=0m
+myself_c=0;37m