summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-config/myth_user_call
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2008-11-08 01:55:11 (GMT)
committerJames Meyer <james.meyer@operamail.com>2008-11-08 01:55:11 (GMT)
commit6c8f178b6c8874623e780d2c049a49b780237654 (patch)
tree31cd168b3e87c9777dc1bcd5d57f4e806a3c97f7 /abs/core-testing/LinHES-config/myth_user_call
parent4287d6026a61f8760633574c059f6e2dead2619d (diff)
downloadlinhes_pkgbuild-6c8f178b6c8874623e780d2c049a49b780237654.zip
linhes_pkgbuild-6c8f178b6c8874623e780d2c049a49b780237654.tar.gz
linhes_pkgbuild-6c8f178b6c8874623e780d2c049a49b780237654.tar.bz2
rename live-installer to LinHES-config
Diffstat (limited to 'abs/core-testing/LinHES-config/myth_user_call')
-rw-r--r--abs/core-testing/LinHES-config/myth_user_call164
1 files changed, 164 insertions, 0 deletions
diff --git a/abs/core-testing/LinHES-config/myth_user_call b/abs/core-testing/LinHES-config/myth_user_call
new file mode 100644
index 0000000..d95e468
--- /dev/null
+++ b/abs/core-testing/LinHES-config/myth_user_call
@@ -0,0 +1,164 @@
+#!/bin/bash
+#Wrapper script to manage USERNAME accounts + web security
+# myth_USERNAME_all -c add -u USERNAME
+# myth_USERNAME_all -c delete -u USERNAME
+# myth_USERNAME_all -c pass -u USERNAME -p pass
+# myth_USERNAME_all -c web -u USERNAME -p pass
+
+INIT_CHECK=TRUE
+FULL_CALL="$@"
+function CHROOT_CHECK {
+ INIT=`ps -p 1 -o comm=`
+ if [ x$INIT = xrunit ]
+ then
+ CHROOT_NEEDED=FALSE
+ else
+ CHROOT_NEEDED=TRUE
+ fi
+}
+
+function store_commands () {
+ echo "$FULL_CALL" >> /root/myth_user_call.out
+ chmod 600 /root/myth_user_call.out
+}
+
+
+function add_user() {
+ if [ $CHROOT_NEEDED = TRUE ]
+ then
+ echo "calling myth_call_user in chroot to add user"
+ store_commands
+ else
+ echo "adding user $USERNAME"
+ useradd -m -s /bin/bash $USERNAME -G audio,video,optical,storage,users
+ fi
+
+}
+
+
+function del_user() {
+ if [ $CHROOT_NEEDED = TRUE ]
+ then
+ echo "calling myth_call_user in chroot to delete user"
+ store_commands
+ else
+ echo "removing user $USERNAME"
+ userdel $USERNAME
+ fi
+
+}
+
+
+function pass_change() {
+ if [ $CHROOT_NEEDED = TRUE ]
+ then
+ echo "calling myth_call_user in chroot to change password"
+ store_commands
+ else
+ echo "changing password for $USERNAME"
+ echo $USERNAME:$PASSWORD | chpasswd
+ fi
+
+}
+
+
+function web_security {
+ echo "this is just a stub"
+
+}
+
+function ARG_ERR() {
+ if [ x$OPTARG = "x" ]
+ then
+ echo "$SWITCH NEEDS AND ARG"
+ exit 11
+ fi
+}
+
+
+function print_help {
+
+ echo "Valid options are:"
+ echo " -c (add|delete|pass|web)"
+ echo " -u USERNAMEname"
+ echo " -p password"
+ exit 1
+}
+
+if [ $# -eq 0 ]
+then
+ print_help
+fi
+
+declare -r OPTSTRING="c:u:p:i"
+while getopts "$OPTSTRING" SWITCH
+do
+ case $SWITCH in
+
+ c) ARG_ERR
+ OPERATION=$OPTARG
+ ;;
+ u) ARG_ERR
+ USERNAME=$OPTARG
+ ;;
+ p) ARG_ERR
+ PASSWORD=$OPTARG
+ ;;
+ i) INIT_CHECK=FALSE
+
+ esac
+done
+
+if [ $INIT_CHECK = TRUE ]
+then
+ CHROOT_CHECK
+else
+ CHROOT_NEEDED=FALSE
+fi
+
+case $OPERATION in
+ add)
+ if [ x$USERNAME = x ]
+ then
+ print_help
+ fi
+ add_user
+ ;;
+ delete)
+ if [ x$USERNAME = x ]
+ then
+ print_help
+ fi
+ del_user
+ ;;
+ pass)
+ if [ x$USERNAME = x ]
+ then
+ print_help
+ fi
+
+ if [ x$PASSWORD = x ]
+ then
+ print_help
+ fi
+ pass_change
+ ;;
+
+ web)
+ if [ x$USERNAME = x ]
+ then
+ print_help
+ fi
+
+
+ if [ x$PASSWORD = x ]
+ then
+ print_help
+ fi
+ echo "adding webUSERNAME $USERNAME with $PASS"
+ ;;
+ *) print_help
+ ;;
+esac
+
+