aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorziggys <ziggys@autistici.org>2018-05-20 21:17:49 -0300
committerziggys <ziggys@autistici.org>2018-05-20 21:17:49 -0300
commit6b866f21e577808ee761361151a500e91b05f1ad (patch)
treed842b69fd1001e686caa267db0db997bef573ee5
parent0c9a6017815a3ff4b7caca59f63031a15211718d (diff)
downloadpupm-legacy.tar
pupm-legacy.zip
Keep legacy versionlegacy
-rw-r--r--pupm.config13
-rwxr-xr-xpupm.sh156
2 files changed, 0 insertions, 169 deletions
diff --git a/pupm.config b/pupm.config
deleted file mode 100644
index b6668c9..0000000
--- a/pupm.config
+++ /dev/null
@@ -1,13 +0,0 @@
-#pupm configuration file
-#use to define script variables
-#empty variables will be treated
-#as default for script
-#run ./pupm.sh -h for help
-#and variables choices
-
-MODULESPATH=
-DIROWNER=root
-DIRGROUP=prosody
-DIRPERMISSIONS=750
-RELOAD=no
-SYSTEMINIT=service
diff --git a/pupm.sh b/pupm.sh
deleted file mode 100755
index ceae061..0000000
--- a/pupm.sh
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/bin/sh
-# -*- ENCODING: UTF-8 -*-
-# Properly Update Prosody Modules
-# a very simple script to do that
-# by ziggys (c) 2018
-# License BSD 2.0 (3-Clause)
-
-# scriptinfo
-VERSION='2.0.2' # Parse variables from commandline
-AUTHOR="ziggys"
-CYEAR=`date +%Y`
-COPYRIGHT="${CYEAR} by ${AUTHOR}"
-
-# usage
-usage (){
-test $# = 0 || echo $@
-echo "$0 version ${VERSION}"
-echo "Copyright (C) ${COPYRIGHT}"
-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 # With no options/args the script"
-echo " # will use variables from default"
-echo " # configuration file (pupm.config)"
-echo
-echo "Usage: $0 [OPTIONS] <args> ... # Using options and args to parse"
-echo" # custom variables from commandline"
-echo
-echo "Options"
-echo " Parse <args> from commandline as custom variables."
-echo " See Configuration File to learn syntax."
-echo
-echo " -d <path> # 'MODULESPATH'"
-echo " -o <user> # 'DIROWNER'"
-echo " -g <group> # 'DIRGROUP'"
-echo " -p <ABC> # 'DIRPERMISSIONS'"
-echo " -r yes | no # 'RELOAD'"
-echo " -s service | runit | systemd # 'SYSTEMINIT'"
-echo " -c <path>/<file> # 'INPUTFILE' or Configuration File"
-echo " -h HELP # Print this help and exit"
-echo
-echo "Example:"
-echo "./pupm.sh -d /home/me/otherpupm.config -g root -p 751 -r yes"
-echo
-echo "The script will be executed reading options from otherpupm.config and"
-echo "will override group with root, permissions with 751 and reload with yes"
-echo "As seen, anyway possible, when '-c file.config' is used, other options are not"
-echo "parsed for obvious reasons."
-echo
-echo "Configuration File"
-echo " pupm.config is provided as example"
-echo
-echo " MODULESPATH <path> # Path to prosody modules. If empty, will default to /usr/lib/prosody/modules"
-echo " DIROWNER <user> # 'MODULESPATH' owner. If empty... root"
-echo " DIRGROUP <group> # 'MODULESPATH' group. If empty... prosody"
-echo " DIRPERMISSIONS <ABC> # 'MODULESPATH' permissions in octal. If empty... 750"
-echo " RELOAD yes | no # yes: reload prosody modules using 'prosodyctl reload'"
-echo " # no: restart prosody service (as 'service prosody restart')"
-echo " # If empty... no"
-echo " SYSTEMINIT service | runit | systemd # service: for sysv, openrc and similar"
-echo " # runit: for void and similar"
-echo " # systemd: if you are stupid enough"
-echo " # If empty... service"
-exit $?
-
-}
-
-# service restart
-service_restart () {
- case ${SYSTEMINIT} in
- service) service prosody restart >> /tmp/pupm.log 2>&1;;
- runit) sv restart prosody >> /tmp/pupm.log 2>&1;;
- systemd) systemctl restart prosody >> /tmp/pupm.log 2>&1;;
- *) echo "Bad service ${SYSTEMINIT}" >> /tmp/pupm.log 2>&1;;
-
- esac
-
-}
-
-# input variables
-INPUTFILE="${PWD}/pupm.config"
-MODULESPATH=`cat ${INPUTFILE} | grep "MODULESPATH=" | sed 's/MODULESPATH=//g; s/ *$//g'`
-DIROWNER=`cat ${INPUTFILE} | grep "DIROWNER=" | sed 's/DIROWNER=//g; s/ *$//g'`
-DIRGROUP=`cat ${INPUTFILE} | grep "DIRGROUP=" | sed 's/DIRGROUP=//g; s/ *$//g'`
-DIRPERMISSIONS=`cat ${INPUTFILE} | grep "DIRPERMISSIONS=" | sed 's/DIRPERMISSIONS=//g; s/ *$//g'`
-RELOAD=`cat ${INPUTFILE} | grep "RELOAD=" | sed 's/RELOAD=//g; s/ *$//g'`
-SYSTEMINIT=`cat ${INPUTFILE} | grep "SYSTEMINIT=" | sed 's/SYSTEMINIT=//g; s/ *$//g'`
-
-# default variables
-: ${MODULESPATH:=/usr/lib/prosody/modules/}
-: ${DIROWNER:=root}
-: ${DIRGROUP:=prosody}
-: ${DIRPERMISSIONS:=750}
-: ${RELOAD:=no}
-: ${SYSTEMINIT:=service}
-
-# general variables
-REALOWNER=`ls -ld ${MODULESPATH} | awk '{ print $3 }'`
-DATE=`date +%d.%m.%Y`
-TIME=`date +%H:%M`
-
-# get options
-while getopts ":d:o:g:p:r:s:c:h" opt ; do
- case ${opt} in
- d) MODULESPATH="${OPTARG}" ;;
- o) DIROWNER="${OPTARG}" ;;
- g) DIRGROUP="${OPTARG}";;
- p) DIRPERMISSIONS="${OPTARG}" ;;
- r) RELOAD="${OPTARG}";;
- s) SYSTEMINIT=${OPTARG};;
- c) INPUTFILE=${OPTARG};;
- \?) echo "Invalid option: -${OPTARG}" 1>&2; exit 2 ;;
- :) echo "Missing argument for -${OPTARG}" 1>&2; exit 2 ;;
- h) usage ;;
-
- esac
-
-done
-
-shift $(($OPTIND -1))
-
-# clean log and relog date
-echo "${DATE} - ${TIME}" > /tmp/pupm.log
-
-# update
-if [ -d ${MODULESPATH} ]; then
- if [ ${REALOWNER} = ${DIROWNER} ]; then
- cd ${MODULESPATH}
- hg pull --update >> /tmp/pupm.log 2>&1
-
- else
- echo "You have no permissions to update the repository modules" >> /tmp/pupm.log 2>&1
- exit $?
-
- fi
-
-else
- echo "The directory ${MODULESPATH} does not exist" >> /tmp/pupm.log 2>&1
-
-fi
-
-# change permissions
-chown ${DIROWNER}:${DIRGROUP} -R ${MODULESPATH} >> /tmp/pupm.log 2>&1
-chmod ${DIRPERMISSIONS} -R ${MODULESPATH} >> /tmp/pupm.log 2>&1
-
-# reload or restart
-case ${RELOAD} in
- yes) prosodyctl reload >> /tmp/pupm.log 2>&1;;
- no) service_restart >> /tmp/pupm.log 2>&1;;
-
-esac
-