AlternC/src/mem_add

37 lines
656 B
Plaintext
Raw Normal View History

2013-02-18 13:11:25 +00:00
#!/bin/bash
2013-02-18 13:11:25 +00:00
if [ $# -ne 2 ] ; then
echo "Usage: sudo mem_add <name> <uid>"
echo " Create the AlternC account <name> having uid number <uid>"
exit 1
fi
2013-02-18 13:11:25 +00:00
name="$1"
uid="$2"
2013-02-18 13:11:25 +00:00
if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then
echo "Account name is incorrect."
exit 2
fi
2013-02-18 13:11:25 +00:00
if [[ ! "$uid" =~ ^([0-9]+)$ ]] ; then
echo "uid is incorrect."
exit 3
fi
2013-02-18 13:11:25 +00:00
if [[ ! "$(id -u)" == "0" ]] ; then
echo "please launch mem_add as root (or using sudo)"
exit 4
fi
2013-02-18 13:11:25 +00:00
# Get the vars and some functions
source /usr/lib/alternc/functions.sh
target="$(get_html_path_by_name "$name")"
2013-02-18 13:11:25 +00:00
mkdir -p "$target"
chmod 2770 "$target"
/usr/lib/alternc/fixperms.sh -u "$uid"