forked from team/makeuser
Including tilde.json
This commit is contained in:
parent
0d26c64916
commit
2c8c3bdfb0
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# $0 A bash script to generate the tilde.json file as described by
|
||||||
|
# http://protocol.club/~datagrok/beta-wiki/tdp.html
|
||||||
|
#
|
||||||
|
# This command takes no arguments, and sends outputs to stdout.
|
||||||
|
# Version 1.2
|
||||||
|
#
|
||||||
|
# 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" : "$SITE_TITLE",
|
||||||
|
"url" : "$SITE",
|
||||||
|
"want_users":$WANT_USERS,
|
||||||
|
"admin_email": "$ADMIN_EMAIL",
|
||||||
|
"signup_url": "$SIGNUP_URL",
|
||||||
|
"description": "$DESCRIPTION",
|
||||||
|
_EOF
|
||||||
|
|
||||||
|
echo -ne "\t\"user_count\":"
|
||||||
|
echo $(for i in $(members tilde); do echo $i; done | sort | uniq | wc -l)","
|
||||||
|
echo -e "\t\"generated_at\" : \"$(date)\","
|
||||||
|
echo -e "\t\"uptime\" : \"$(uptime | cut -f1 -d,)\","
|
||||||
|
|
||||||
|
member_count=$(for i in $(members tilde); do echo $i; done | sort | uniq | wc -l)
|
||||||
|
|
||||||
|
echo -e "\t\"users\": ["
|
||||||
|
|
||||||
|
for i in $(for i in $(members tilde); do echo $i; done | sort | uniq); do
|
||||||
|
let count=$count+1
|
||||||
|
echo -e "\t{\n\t\t\"user_name\": \"$i\","
|
||||||
|
set mod_time= "$(stat -c '%Y' /home/$i/public_html/index.* 2> /dev/null | head -n1)"
|
||||||
|
if [ ! "$mod_time" == "" ]; then
|
||||||
|
echo -e "\t\t\"mtime\" : \"0\","
|
||||||
|
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 $SITE/~$i -so - |grep -iPo '(?<=<title>)(.*)(?=</title>)')"\""
|
||||||
|
if [ $count -eq $(for i in $(members tilde); do echo $i; done | sort | uniq | wc -l) ]; then
|
||||||
|
echo -e "\t}"
|
||||||
|
else
|
||||||
|
echo -e "\t},"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e "\t],"
|
||||||
|
echo -e "\t\"generated_by\":\"bash_tdp\""
|
||||||
|
echo "}"
|
||||||
|
|
4
makeuser
4
makeuser
|
@ -11,6 +11,9 @@ LIST_NAME="thunix-join@lists.tildeverse.org"
|
||||||
ADMIN_EMAIL="root@thunix.net"
|
ADMIN_EMAIL="root@thunix.net"
|
||||||
EMAIL_TEMPLATE="email.tmpl"
|
EMAIL_TEMPLATE="email.tmpl"
|
||||||
YAML_FILE="$1.yml"
|
YAML_FILE="$1.yml"
|
||||||
|
GEN_TDP="./gen_tdp"
|
||||||
|
TILDE_JSON="var/www/thunix.cf/tilde.json"
|
||||||
|
|
||||||
# This one for team
|
# This one for team
|
||||||
# ZNC_USER="/home/znc/add_znc_user.sh"
|
# ZNC_USER="/home/znc/add_znc_user.sh"
|
||||||
|
|
||||||
|
@ -95,6 +98,7 @@ case $1 in
|
||||||
git commit -am "Adding user $1"
|
git commit -am "Adding user $1"
|
||||||
git push
|
git push
|
||||||
cd $place
|
cd $place
|
||||||
|
$GEN_TDP | sudo tee $TILDE_JSON
|
||||||
# End Thunix specific section
|
# End Thunix specific section
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# makeuser - tilde new user creation
|
||||||
|
# Usage: makeuser [-h|--help] <username> <email> "<pubkey>"
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Forked from tilde.team's make user script (
|
||||||
|
PROGNAME=${0##*/}
|
||||||
|
VERSION="0.4"
|
||||||
|
LIST_NAME="thunix-join@lists.tildeverse.org"
|
||||||
|
ADMIN_EMAIL="root@thunix.net"
|
||||||
|
EMAIL_TEMPLATE="email.tmpl"
|
||||||
|
YAML_FILE="$1.yml"
|
||||||
|
# This one for team
|
||||||
|
# ZNC_USER="/home/znc/add_znc_user.sh"
|
||||||
|
|
||||||
|
# This one for Thunix
|
||||||
|
ZNC_USER="/var/lib/znc/create-znc_account.sh"
|
||||||
|
|
||||||
|
# Set location to your repo for ansible here
|
||||||
|
# It is only needed for thunix
|
||||||
|
REPO_LOCATION="/home/ubergeek/repos/ansible/"
|
||||||
|
|
||||||
|
error_exit() {
|
||||||
|
echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo -e "usage: $PROGNAME [-h|--help] <username> <email> \"<pubkey>\""
|
||||||
|
}
|
||||||
|
|
||||||
|
sub_to_list() {
|
||||||
|
echo "
|
||||||
|
From: $1
|
||||||
|
Subject: subscribe
|
||||||
|
" | sudo -u $1 mail $LIST_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $(id -u) == 0 ]] && error_exit "Do not run this script as root."
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
-h | --help)
|
||||||
|
usage; exit ;;
|
||||||
|
-* | --*)
|
||||||
|
usage; error_exit "unknown option $1" ;;
|
||||||
|
*)
|
||||||
|
[[ $# -ne 3 ]] && error_exit "not enough args"
|
||||||
|
echo "adding new user $1"
|
||||||
|
newpw=`pwgen -1B 10`
|
||||||
|
pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');")
|
||||||
|
# sudo useradd -m -g 1000 -p $pwcrypt -s /bin/bash $1 || exit 1
|
||||||
|
# This is the welcome for team.
|
||||||
|
# sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" $EMAIL_TEMPLATE | sudo mail $1 $2 $ADMIN_EMAIL
|
||||||
|
|
||||||
|
# This is the welcome email for thunix
|
||||||
|
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" email.tmpl | sudo mail -s "Welcome to Thunix!" $2
|
||||||
|
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" email.tmpl | sudo mail -s "Welcome to Thunix!" $ADMIN_EMAIL
|
||||||
|
sub_to_list $1
|
||||||
|
|
||||||
|
# This line is for team
|
||||||
|
# sudo -u znc $ZNC_USER $1
|
||||||
|
# This one is for Thunix
|
||||||
|
sudo $ZNC_USER $1 $pwcrypt
|
||||||
|
|
||||||
|
# We don't need this for thunix, since ansible will do it
|
||||||
|
# echo "$3" | tee /home/$1/.ssh/authorized_keys
|
||||||
|
|
||||||
|
# If root doesn't have a fediverse account, comment this out
|
||||||
|
# sudo toot "welcome new user ~$1!"
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
|
@ -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."
|
Loading…
Reference in New Issue