functions-users.sh (209552) | functions-users.sh (211730) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# | 1#!/bin/sh 2#- 3# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# |
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-users.sh 209552 2010-06-27 16:46:11Z imp $ | 26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-users.sh 211730 2010-08-24 06:11:46Z imp $ |
27 28# Functions which runs commands on the system 29 30. ${BACKEND}/functions.sh 31. ${BACKEND}/functions-parse.sh 32 33 34# Function which checks and sets up auto-login for a user if specified --- 32 unchanged lines hidden (view full) --- 67# Function which reads in the config, and adds any users specified 68setup_users() 69{ 70 71 # We are ready to start setting up the users, lets read the config 72 while read line 73 do 74 | 27 28# Functions which runs commands on the system 29 30. ${BACKEND}/functions.sh 31. ${BACKEND}/functions-parse.sh 32 33 34# Function which checks and sets up auto-login for a user if specified --- 32 unchanged lines hidden (view full) --- 67# Function which reads in the config, and adds any users specified 68setup_users() 69{ 70 71 # We are ready to start setting up the users, lets read the config 72 while read line 73 do 74 |
75 echo $line | grep "^userName=" >/dev/null 2>/dev/null 76 if [ "$?" = "0" ] 77 then 78 get_value_from_string "${line}" 79 USERNAME="$VAL" 80 fi | 75 echo $line | grep "^userName=" >/dev/null 2>/dev/null 76 if [ "$?" = "0" ] 77 then 78 get_value_from_string "${line}" 79 USERNAME="$VAL" 80 fi |
81 | 81 |
82 echo $line | grep "^userComment=" >/dev/null 2>/dev/null 83 if [ "$?" = "0" ] 84 then 85 get_value_from_string "${line}" 86 USERCOMMENT="$VAL" 87 fi | 82 echo $line | grep "^userComment=" >/dev/null 2>/dev/null 83 if [ "$?" = "0" ] 84 then 85 get_value_from_string "${line}" 86 USERCOMMENT="$VAL" 87 fi |
88 | 88 |
89 echo $line | grep "^userPass=" >/dev/null 2>/dev/null 90 if [ "$?" = "0" ] 91 then 92 get_value_from_string "${line}" 93 USERPASS="$VAL" 94 fi | 89 echo $line | grep "^userPass=" >/dev/null 2>/dev/null 90 if [ "$?" = "0" ] 91 then 92 get_value_from_string "${line}" 93 USERPASS="$VAL" 94 fi |
95 | 95 |
96 echo $line | grep "^userShell=" >/dev/null 2>/dev/null 97 if [ "$?" = "0" ] 98 then 99 get_value_from_string "${line}" 100 strip_white_space "$VAL" 101 USERSHELL="$VAL" 102 fi | 96 echo $line | grep "^userShell=" >/dev/null 2>/dev/null 97 if [ "$?" = "0" ] 98 then 99 get_value_from_string "${line}" 100 strip_white_space "$VAL" 101 USERSHELL="$VAL" 102 fi |
103 | 103 |
104 echo $line | grep "^userHome=" >/dev/null 2>/dev/null 105 if [ "$?" = "0" ] 106 then 107 get_value_from_string "${line}" 108 USERHOME="$VAL" 109 fi | 104 echo $line | grep "^userHome=" >/dev/null 2>/dev/null 105 if [ "$?" = "0" ] 106 then 107 get_value_from_string "${line}" 108 USERHOME="$VAL" 109 fi |
110 | 110 |
111 echo $line | grep "^userGroups=" >/dev/null 2>/dev/null 112 if [ "$?" = "0" ] 113 then 114 get_value_from_string "${line}" 115 USERGROUPS="$VAL" 116 fi | 111 echo $line | grep "^userGroups=" >/dev/null 2>/dev/null 112 if [ "$?" = "0" ] 113 then 114 get_value_from_string "${line}" 115 USERGROUPS="$VAL" 116 fi |
117 118 | 117 118 |
119 echo $line | grep "^commitUser" >/dev/null 2>/dev/null 120 if [ "$?" = "0" ] 121 then 122 # Found our flag to commit this user, lets check and do it 123 if [ ! -z "${USERNAME}" ] 124 then | 119 echo $line | grep "^commitUser" >/dev/null 2>/dev/null 120 if [ "$?" = "0" ] 121 then 122 # Found our flag to commit this user, lets check and do it 123 if [ ! -z "${USERNAME}" ] 124 then |
125 | 125 |
126 # Now add this user to the system, by building our args list 127 ARGS="-n ${USERNAME}" | 126 # Now add this user to the system, by building our args list 127 ARGS="-n ${USERNAME}" |
128 | 128 |
129 if [ ! -z "${USERCOMMENT}" ] 130 then 131 ARGS="${ARGS} -c \"${USERCOMMENT}\"" 132 fi | 129 if [ ! -z "${USERCOMMENT}" ] 130 then 131 ARGS="${ARGS} -c \"${USERCOMMENT}\"" 132 fi |
133 | 133 |
134 if [ ! -z "${USERPASS}" ] 135 then 136 ARGS="${ARGS} -h 0" 137 echo "${USERPASS}" >${FSMNT}/.tmpPass 138 else 139 ARGS="${ARGS} -h -" 140 rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null 141 fi | 134 if [ ! -z "${USERPASS}" ] 135 then 136 ARGS="${ARGS} -h 0" 137 echo "${USERPASS}" >${FSMNT}/.tmpPass 138 else 139 ARGS="${ARGS} -h -" 140 rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null 141 fi |
142 | 142 |
143 if [ ! -z "${USERSHELL}" ] 144 then 145 ARGS="${ARGS} -s \"${USERSHELL}\"" 146 else 147 ARGS="${ARGS} -s \"/nonexistant\"" 148 fi | 143 if [ ! -z "${USERSHELL}" ] 144 then 145 ARGS="${ARGS} -s \"${USERSHELL}\"" 146 else 147 ARGS="${ARGS} -s \"/nonexistant\"" 148 fi |
149 | 149 |
150 if [ ! -z "${USERHOME}" ] 151 then 152 ARGS="${ARGS} -m -d \"${USERHOME}\"" 153 fi | 150 if [ ! -z "${USERHOME}" ] 151 then 152 ARGS="${ARGS} -m -d \"${USERHOME}\"" 153 fi |
154 | 154 |
155 if [ ! -z "${USERGROUPS}" ] 156 then 157 ARGS="${ARGS} -G \"${USERGROUPS}\"" 158 fi | 155 if [ ! -z "${USERGROUPS}" ] 156 then 157 ARGS="${ARGS} -G \"${USERGROUPS}\"" 158 fi |
159 | 159 |
160 add_user "${ARGS}" | 160 add_user "${ARGS}" |
161 | 161 |
162 # Unset our vars before looking for any more users 163 unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS 164 else 165 exit_err "ERROR: commitUser was called without any userName= entry!!!" 166 fi 167 fi | 162 # Unset our vars before looking for any more users 163 unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS 164 else 165 exit_err "ERROR: commitUser was called without any userName= entry!!!" 166 fi 167 fi |
168 169 done <${CFGF} 170 171 172 # Check if we need to enable a user to auto-login to the desktop 173 check_autologin 174 175}; | 168 169 done <${CFGF} 170 171 172 # Check if we need to enable a user to auto-login to the desktop 173 check_autologin 174 175}; |