diff --git a/include/functions b/include/functions new file mode 100644 index 0000000..618439f --- /dev/null +++ b/include/functions @@ -0,0 +1,15 @@ +#!/bin/bash +#Common functions used for several makeuser scripts + +error_exit() { + echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2 + exit 1 +} + +usage() { + echo -e "usage: $PROGNAME [-h|--help] \"\"" +} + +sub_to_list() { + echo "From: $1 Subject: subscribe" | sudo -u $1 mail $LIST_NAME +} diff --git a/makeuser b/makeuser index ef31b74..72b6e9e 100755 --- a/makeuser +++ b/makeuser @@ -12,21 +12,7 @@ CONFIG=./setenv . $CONFIG -error_exit() { - echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2 - exit 1 -} - -usage() { - echo -e "usage: $PROGNAME [-h|--help] \"\"" -} - -sub_to_list() { - echo " -From: $1 -Subject: subscribe -" | sudo -u $1 mail $LIST_NAME -} +source include/functions [[ $(id -u) == 0 ]] && error_exit "Do not run this script as root." diff --git a/makeuser_no_ansible b/makeuser_no_ansible index 262ed80..9b8543e 100755 --- a/makeuser_no_ansible +++ b/makeuser_no_ansible @@ -11,21 +11,7 @@ CONFIG=./setenv . $CONFIG -error_exit() { - echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2 - exit 1 -} - -usage() { - echo -e "usage: $PROGNAME [-h|--help] \"\"" -} - -sub_to_list() { - echo " -From: $1 -Subject: subscribe -" | sudo -u $1 mail $LIST_NAME -} +source include/functions [[ $(id -u) == 0 ]] && error_exit "Do not run this script as root."