Working script.
* Add the AFS-script * Make the script idempotent * Fix a few bugs
This commit is contained in:
parent
da980ed894
commit
d36e713a62
2 changed files with 36 additions and 24 deletions
28
make-user
28
make-user
|
@ -4,7 +4,7 @@
|
||||||
# POC - Make a user, never tested
|
# POC - Make a user, never tested
|
||||||
|
|
||||||
abort() {
|
abort() {
|
||||||
echo "ABORT: $@"
|
echo -e "ABORT: $@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,8 @@ log "Query finger.json for $1"
|
||||||
|
|
||||||
log "Check for $1 in KDC"
|
log "Check for $1 in KDC"
|
||||||
if echo get $1 | kadmin | grep -q "$1@STACKEN.KTH.SE"; then
|
if echo get $1 | kadmin | grep -q "$1@STACKEN.KTH.SE"; then
|
||||||
abort "Principal $1 exists in KDC, abort!"
|
log "Principal $1 exists in KDC, ignore"
|
||||||
fi
|
else
|
||||||
|
|
||||||
log "Add $1 to KDC"
|
log "Add $1 to KDC"
|
||||||
kadmin add \
|
kadmin add \
|
||||||
--max-ticket-life="10 hours" \
|
--max-ticket-life="10 hours" \
|
||||||
|
@ -59,9 +58,7 @@ kadmin add \
|
||||||
--attributes="requires-pre-auth, disallow-postdated" \
|
--attributes="requires-pre-auth, disallow-postdated" \
|
||||||
--policy=default \
|
--policy=default \
|
||||||
$1
|
$1
|
||||||
|
fi
|
||||||
cd /afs/stacken.kth.se/admin/passwd/
|
|
||||||
grep -qE "^$1" master.passwd && abort "User $1 is already part of master.passwd"
|
|
||||||
|
|
||||||
next_passwd_uid() {
|
next_passwd_uid() {
|
||||||
for n in $(seq 18000 19000); do
|
for n in $(seq 18000 19000); do
|
||||||
|
@ -72,6 +69,10 @@ next_passwd_uid() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cd /afs/stacken.kth.se/admin/passwd/
|
||||||
|
if grep -qE "^$1" master.passwd; then
|
||||||
|
log "User $1 is already part of master.passwd"
|
||||||
|
else
|
||||||
PASSWD_UID=$(next_passwd_uid)
|
PASSWD_UID=$(next_passwd_uid)
|
||||||
log "Add $1 ($2) to master.passwd with UID $PASSWD_UID"
|
log "Add $1 ($2) to master.passwd with UID $PASSWD_UID"
|
||||||
[ -z $PASSWD_UID ] && abort "No free UID found"
|
[ -z $PASSWD_UID ] && abort "No free UID found"
|
||||||
|
@ -79,6 +80,17 @@ co -u master.passwd
|
||||||
echo "$1:*:$PASSWD_UID:30::0:0:$2:/afs/stacken.kth.se/home/$1:/bin/bash" \
|
echo "$1:*:$PASSWD_UID:30::0:0:$2:/afs/stacken.kth.se/home/$1:/bin/bash" \
|
||||||
>> master.passwd
|
>> master.passwd
|
||||||
ci -l -m "Added user $1 ($2) with $0" master.passwd
|
ci -l -m "Added user $1 ($2) with $0" master.passwd
|
||||||
|
log "Build database"
|
||||||
|
make
|
||||||
|
fi
|
||||||
|
|
||||||
log "Setup AFS volume"
|
log "Setup AFS volume"
|
||||||
# TODO
|
|
||||||
|
if [ -e "/afs/stacken.kth.se/home/$1" ]; then
|
||||||
|
log "Home dir for user $1 exists"
|
||||||
|
else
|
||||||
|
/afs/stacken.kth.se/src/script/createuser $1 beef.stacken.kth.se vicepa
|
||||||
|
vos release home
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Looks good, all done!"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import json
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
finger = "/afs/stacken.kth.se/home/stacken/Private/finger.json"
|
finger = "/afs/stacken.kth.se/home/stacken/Private/finger_txt/finger.json"
|
||||||
|
|
||||||
fd = open(finger, 'r')
|
fd = open(finger, 'r')
|
||||||
data = json.load(fd)
|
data = json.load(fd)
|
||||||
|
|
Loading…
Add table
Reference in a new issue