From faccd9b2c3a4ac0977e6d114e7f1901a21cf597f Mon Sep 17 00:00:00 2001 From: Ubergeek Date: Tue, 5 Nov 2019 00:09:27 +0000 Subject: [PATCH] Added separate config file, and bummped version --- gen_tdp | 25 +++++++++++++++++-------- setenv.sh | 10 ++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 setenv.sh diff --git a/gen_tdp b/gen_tdp index 1ef0871..2ba809e 100755 --- a/gen_tdp +++ b/gen_tdp @@ -5,21 +5,30 @@ # http://protocol.club/~datagrok/beta-wiki/tdp.html # # This command takes no arguments, and sends outputs to stdout. -# Version 1.0 +# Version 1.1 # # Licensed under a the AGPL 3.0 or later, by Ubergeek (ubergeek@thunix.net) # https://www.gnu.org/licenses/gpl-3.0.en.html # ############################################################################### +CONFIG=./setenv.sh + +if [ ! -f "$CONFIG" ]; then + echo "Config file does not exist, or not at the location specified. Please create the file, or correct the location." + exit 1 +fi + +. $CONFIG + cat << _EOF { - "name" : "thunix", - "url" : "https://thunix.net", - "want_users":true, - "admin_email": "root@thunix.net", - "signup_url": "https://www.thunix.net/signup", - "description": "Thunix is a community, centered around access to a public *nix system. Thunix offers shell accounts with complete set of programming tools, and follows a continuous integration-continuous deployment of system configuration.", + "name" : "$SITE_TITLE", + "url" : "$SITE", + "want_users":$WANT_USERS, + "admin_email": "$ADMIN_EMAIL", + "signup_url": "$SIGNUP_URL", + "description": "$DESCRIPTION", _EOF echo -ne "\t\"user_count\":" @@ -40,7 +49,7 @@ for i in $(for i in $(members tilde); do echo $i; done | sort | uniq); do else echo -e "\t\t\"mtime\" : \"$(stat -c '%Y' /home/$i/public_html/index.* 2> /dev/null | head -n1)\"," fi - echo -e "\t\t\"title\" : \""$(curl -L https://www.thunix.net/~$i -so - |grep -iPo '(?<=)(.*)(?=)')"\"" + echo -e "\t\t\"title\" : \""$(curl -L $SITE/~$i -so - |grep -iPo '(?<=)(.*)(?=)')"\"" if [ $count -eq $(for i in $(members tilde); do echo $i; done | sort | uniq | wc -l) ]; then echo -e "\t}" else diff --git a/setenv.sh b/setenv.sh new file mode 100644 index 0000000..eee6c26 --- /dev/null +++ b/setenv.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Here is where you set config variables. + +export SITE_TITLE="Thunix" +export SITE="https://thunix.net" +export WANT_USERS="true" +export ADMIN_EMAIL="root@thunix.net" +export SIGNUP_URL="https://thunix.net/signup" +export DESCRIPTION="Thunix is a community, centered around access to a public *nix system. Thunix offers shell accounts with complete set of programming tools, and follows a continuous integration-continuous deployment of system configuration."