aboutsummaryrefslogtreecommitdiff
path: root/pupm.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pupm.sh')
-rwxr-xr-xpupm.sh72
1 files changed, 43 insertions, 29 deletions
diff --git a/pupm.sh b/pupm.sh
index 1f8abaa..1bb67ba 100755
--- a/pupm.sh
+++ b/pupm.sh
@@ -6,42 +6,55 @@
# License BSD 2.0 (3-Clause)
# scriptinfo
-VERSION='3.0.2' # Check some sintax and fix minor bugs
+SCRIPTNAME="${0##*/}"
+SCRIPTNAME="${SCRIPTNAME%%.sh}"
+
+VERSION='3.0.3
AUTHOR="ziggys"
+LICENSE="BSD 2.0 (3-Clause)"
+
+# usage
+usage () {
+test "$#" = 0 || printf "%s %s\\n" "${SCRIPTNAME}" "$@"
+cat << EOF | fold -s
+${SCRIPTNAME} version ${VERSION}
+ by ${AUTHOR}
+ License: ${LICENSE}
+
+${SCRIPTNAME} comes with ABSOLUTELY NO WARRANTY. This is free software, and you
+ you are welcome to redistribute it under certain conditions. See the BSD 2.0
+ license for details.
+
+${SCRIPTNAME} is a symply shellscript for properly update prosody modules
+
+Usage: ${SCRIPTNAME} <configile>
+Usage: ${SCRIPTNAME} pupm.config
-# usash
-show_help () {
-test "${#}" = 0 || echo "${@}"
-echo "${0##*/} version ${VERSION}"
-echo " Copyright (C) 2018 by ${AUTHOR}"
-echo
-echo "${0##*/} comes with ABSOLUTELY NO WARRANTY. This is free software, and you"
-echo " are welcome to redistribute it under certain conditions. See the BSD 2.0"
-echo " license for details"
-echo
-echo "${0##*/} is a simply shellscript for properly update prosody modules"
-echo
-echo "Usage: "${0}" <configfile>"
-echo
-echo "Usage: "${0}" pupm.config"
-echo
-exit "${?}"
+For more details about this script go to
+Official Repository: https://git.p4g.club/git/pupm
+Mirror Repository: https://gitgud.io/ziggys/pupm
+EOF
+exit 0
}
# apdeit
update () {
# chek modiulspadz ouunership
- test -O "${MODULESPATH}" \
- && printf "you own the modulespath" > /dev/null \
- || chown "${USER}" -R "${MODULESPATH}" >> "${PUPMLOG}" 2>&1
+ if [ -O "${MODULESPATH}" ]; then
+ printf "you own the modulespath" > /dev/null
+ else
+ chown "${USER}" -R "${MODULESPATH}" >> "${PUPMLOG}" 2>&1
+ fi
# apdeit modiuls
cd "${MODULESPATH}" || return 2
- test ! -d "${HGDIR}" \
- && printf "abort: no repository found in %s\\n" "${MODULESPATH}" >> "${PUPMLOG}" \
- && exit 2 \
- || hg pull --update >> "${PUPMLOG}" 2>&1
+ if [ ! -d "${HGDIR}" ]; then
+ printf "err: no repository found in %s\\n" "${MODULESPATH}" >> "${PUPMLOG}"
+ exit 2
+ else
+ hg pull --update >> "${PUPMLOG}" 2>&1
+ fi
# meik modiulspadz sequiur an ridabel tu prosody
chown "${OWNER}":"${GROUP}" -R "${MODULESPATH}" >> "${PUPMLOG}" 2>&1
@@ -54,13 +67,13 @@ service_restart () {
service) service prosody restart >> "${PUPMLOG}" 2>&1;;
runit) sv restart prosody >> "${PUPMLOG}" 2>&1;;
systemd) systemctl restart prosody >> "${PUPMLOG}" 2>&1;;
- *) printf "init: not supported %s\\n" "${SYSTEMINIT}" >> "${PUPMLOG}" 2>&1;;
+ *) printf "init: not supported %s\\n" "${SYSTEMINIT}" >> "${PUPMLOG}";;
esac
}
# variabels dat comz from config
CONFIG="${1?"Usage: ${0} <configfile>"}"
-test -z "${CONFIG}" && show_help "${@}"
+test -z "${CONFIG}" && usage "$@"
INPUT="$(mktemp)"
sed '/^#/ d; s/;[ \t].*//g; s/;$//g; s/[ \t]*$//g' "${CONFIG}" > "${INPUT}"
@@ -86,8 +99,9 @@ HGDIR=".hg"
PUPMLOG="$(mktemp)"
# inizial comandz
-printf "%s\\n" "${DATE}" > "${PUPMLOG}"
-test -d "${MODULESPATH}" || printf "%s is not a directory" "${MODULESPATH}" >> "${PUPMLOG}"
+printf "%s\\n" "${DATE}" > "${PUPMLOG}"i
+test -d "${MODULESPATH}" \
+ || printf "%s is not a directory" "${MODULESPATH}" >> "${PUPMLOG}"
update