Commit dad74fb1 authored by Johannes Kiesel's avatar Johannes Kiesel

close

parent 4502993d
#!/bin/bash
#!/usr/bin/env bash
### \b
### Create a new user on the webis virtual machine (webis VM).
### Requires your login account on webis.uni-weimar.de to be in the webis group.
### See the comments in this file for installation instructions.
### \b
### Copyright 2019-today
### \b
### Author: Johannes Kiesel
### \b
### Install.
### \b
### On webis.uni-weimar.de:
### \b - sudo visudo
### \b
### \b # Allow members of group webis to run /usr/bin/webisuseradd
### \b %webis ALL=/usr/bin/webisuseradd
### \b
### \b - sudo vim /usr/bin/webisuseradd
### \b
### \b #!/bin/bash
### \b newlogin=$1
### \b
### \b if [ -z "$newlogin" ];then
### \b echo "Usage: $0 <newlogin>"
### \b exit 1
### \b fi
### \b
### \b useradd -g webis -G webisstud -s /bin/bash -m -d /home/"$newlogin" "$newlogin"
### \b passwd "$newlogin"
### \b chage -d 0 "$newlogin"
### \b
### \b - sudo chmod +x /usr/bin/webisuseradd
. "$WEBIS_LIB_PATH"/bashhelper.sh
. "$WEBIS_LIB_PATH"/shflags
###
### : -l : --login : str :: Your own login name on webis.uni-weimar.de [default is the current name]
### : name ::
### : fullname ::
# Install.
#
# On webis.uni-weimar.de:
# - sudo visudo
#
# # Allow members of group webis to run /usr/bin/webisuseradd
# %webis ALL=/usr/bin/webisuseradd
#
# - sudo vim /usr/bin/webisuseradd
#
# #!/bin/bash
# newlogin=$1
# fullname=$2
#
# if [ $# -ne 2 ];then
# echo "Usage: $0 <newlogin> \"<fullname>\""
# exit 1
# fi
#
# useradd -g webis -G webisstud -s /bin/bash -m -d /home/"$newlogin" "$newlogin"
# passwd "$newlogin"
# chage -d 0 "$newlogin"
# chfn -f "$fullname" "$newlogin"
#
# - sudo chmod +x /usr/bin/webisuseradd
if [ -n "$WEBIS_LIB_PATH" ]; then
. "${WEBIS_LIB_PATH}/bashhelper.sh"
fi
check_tools ssh
#
# Define usage screen.
#
usage() {
echo "
usage:
$(basename "$0") newlogin [yourlogin]
description:
create a new webis staff user on the webis virtual machine
requires your login account on webis.uni-weimar.de to be in the webis group
examples:
$(basename "$0") stein
"
exit 1
}
#
# Define command line arguments and parse them.
#
FLAGS_HELP=$(usage)
export FLAGS_HELP
FLAGS "$@" || exit 1 # Parse command line arguments.
eval set -- "${FLAGS_ARGV}"
#
#
#
main() {
if [ "$#" -eq 0 ]; then
logError "Missing arguments see:"
usage
fi
logInfo "creating $1"
user=$2
if [ -z "$user" ];then
user="$USER"
fi
logInfo "Note you may have to enter your password twice, as the account creation works by sudo"
logInfo "Now connecting to webis.uni-weimar.de as $user"
name="$1"
ssh $user@webis.uni-weimar.de -t "sudo /usr/bin/webisuseradd \"$name\""
}
#
# Start program with parameters.
#
main "$@"
login="${ARG_LOGIN}"
if [ -z "$login" ];then
login="$USER"
fi
name="${ARG_NAME}"
fullname="${ARG_FULLNAME}"
logInfo "creating ${name} with full name \"${fullname}\""
logInfo "Note you may have to enter your password twice, as the account creation works by sudo"
logInfo "Now connecting to webis.uni-weimar.de as ${login}"
ssh ${login}@webis.uni-weimar.de -t "sudo /usr/bin/webisuseradd \"${name}\" \"${fullname}\""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment