Project

General

Profile

Download (3.56 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
# Functions which runs commands on the system
3

    
4
. ${BACKEND}/functions.sh
5
. ${BACKEND}/functions-parse.sh
6

    
7

    
8
# Function which checks and sets up auto-login for a user if specified
9
check_autologin()
10
{
11
  get_value_from_cfg autoLoginUser
12
  if [ ! -z "${VAL}"  -a "${INSTALLTYPE}" = "PCBSD" ]
13
  then
14
    AUTOU="${VAL}"
15
    # Add the auto-login user line
16
    sed -i.bak "s/AutoLoginUser=/AutoLoginUser=${AUTOU}/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
17

    
18
    # Add the auto-login user line
19
    sed -i.bak "s/AutoLoginEnable=false/AutoLoginEnable=true/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
20

    
21
  fi
22
};
23

    
24
# Function which actually runs the adduser command on the filesystem
25
add_user()
26
{
27
 ARGS="${1}"
28

    
29
 if [ -e "${FSMNT}/.tmpPass" ]
30
 then
31
   # Add a user with a supplied password
32
   run_chroot_cmd "cat /.tmpPass | pw useradd ${ARGS}"
33
   rc_halt "rm ${FSMNT}/.tmpPass"
34
 else
35
   # Add a user with no password
36
   run_chroot_cmd "cat /.tmpPass | pw useradd ${ARGS}"
37
 fi
38

    
39
};
40

    
41
# Function which reads in the config, and adds any users specified
42
setup_users()
43
{
44

    
45
  # We are ready to start setting up the users, lets read the config
46
  while read line
47
  do
48

    
49
     echo $line | grep "^userName=" >/dev/null 2>/dev/null
50
     if [ "$?" = "0" ]
51
     then
52
       get_value_from_string "${line}"
53
       USERNAME="$VAL"
54
     fi
55

    
56
     echo $line | grep "^userComment=" >/dev/null 2>/dev/null
57
     if [ "$?" = "0" ]
58
     then
59
       get_value_from_string "${line}"
60
       USERCOMMENT="$VAL"
61
     fi
62

    
63
     echo $line | grep "^userPass=" >/dev/null 2>/dev/null
64
     if [ "$?" = "0" ]
65
     then
66
       get_value_from_string "${line}"
67
       USERPASS="$VAL"
68
     fi
69

    
70
     echo $line | grep "^userShell=" >/dev/null 2>/dev/null
71
     if [ "$?" = "0" ]
72
     then
73
       get_value_from_string "${line}"
74
       strip_white_space "$VAL"
75
       USERSHELL="$VAL"
76
     fi
77

    
78
     echo $line | grep "^userHome=" >/dev/null 2>/dev/null
79
     if [ "$?" = "0" ]
80
     then
81
       get_value_from_string "${line}"
82
       USERHOME="$VAL"
83
     fi
84

    
85
     echo $line | grep "^userGroups=" >/dev/null 2>/dev/null
86
     if [ "$?" = "0" ]
87
     then
88
       get_value_from_string "${line}"
89
       USERGROUPS="$VAL"
90
     fi
91

    
92

    
93
     echo $line | grep "^commitUser" >/dev/null 2>/dev/null
94
     if [ "$?" = "0" ]
95
     then
96
       # Found our flag to commit this user, lets check and do it
97
       if [ ! -z "${USERNAME}" ]
98
       then
99

    
100
         # Now add this user to the system, by building our args list
101
         ARGS="-n ${USERNAME}"
102

    
103
         if [ ! -z "${USERCOMMENT}" ]
104
         then
105
           ARGS="${ARGS} -c \"${USERCOMMENT}\""
106
         fi
107
         
108
         if [ ! -z "${USERPASS}" ]
109
         then
110
           ARGS="${ARGS} -h 0"
111
           echo "${USERPASS}" >${FSMNT}/.tmpPass
112
         else
113
           ARGS="${ARGS} -h -"
114
           rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
115
         fi
116

    
117
         if [ ! -z "${USERSHELL}" ]
118
         then
119
           ARGS="${ARGS} -s \"${USERSHELL}\""
120
         else
121
           ARGS="${ARGS} -s \"/nonexistant\""
122
         fi
123
         
124
         if [ ! -z "${USERHOME}" ]
125
         then
126
           ARGS="${ARGS} -m -d \"${USERHOME}\""
127
         fi
128

    
129
         if [ ! -z "${USERGROUPS}" ]
130
         then
131
           ARGS="${ARGS} -G \"${USERGROUPS}\""
132
         fi
133

    
134
         add_user "${ARGS}"
135

    
136
         # Unset our vars before looking for any more users
137
         unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS
138
       else
139
         exit_err "ERROR: commitUser was called without any userName= entry!!!" 
140
       fi
141
     fi
142

    
143
  done <${CFGF}
144

    
145

    
146
  # Check if we need to enable a user to auto-login to the desktop
147
  check_autologin
148

    
149
};
(15-15/18)