| 1 | #!/bin/bash |
| 2 | # Steven Shiau <steven _at_ clonezilla org> |
| 3 | # Ceasar Sun <ceasar _at_ nchc org tw> |
| 4 | # License: GPL |
| 5 | # Description: To set the login mode for DRBL clients |
| 6 | |
| 7 | # Load DRBL setting and functions |
| 8 | DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" |
| 9 | |
| 10 | . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions |
| 11 | |
| 12 | # |
| 13 | PWD_NO_0_1_MSG="Note!!! To avoid confusion, these random password does NOT contain digit 0 (zero) and digit 1 (one)!!!" |
| 14 | |
| 15 | # |
| 16 | usage() { |
| 17 | echo "Switch the login mode for DRBL clients." |
| 18 | echo "Usage: $0 [Options]" |
| 19 | echo "Options:" |
| 20 | language_help_prompt_by_idx_no |
| 21 | echo "-a, --auto: auto login for clients" |
| 22 | echo "-g, --no-gen-ssi do NOT generate DRBL SSI template tarball." |
| 23 | echo "-h, --host IP_ADDRESS: set login mode ony for the host with IP_ADDRESS instead of all DRBL clients" |
| 24 | echo "-n, --normal: normal login for clients" |
| 25 | echo "-t, --timed: timed login within time TIMED_LOGIN_TIME (sec)" |
| 26 | echo "-p, --password_opt: the password option for auto and timed login." |
| 27 | echo "-u, --no_nis_update: do NOT run NIS update" |
| 28 | echo "-v, --verbose: verbose mode." |
| 29 | echo "PASSWORD_OPT:" |
| 30 | echo "If one digit, it's the length of randomly created password." |
| 31 | echo "If more than one character, it's the password (i.e. if you enter \"drblclient\", then the password is \"drblclient\")." |
| 32 | echo "If blank, it will be randomly generated with some (say:8) characters." |
| 33 | } |
| 34 | |
| 35 | # |
| 36 | check_if_root |
| 37 | |
| 38 | # Get the $GDM_CFG/$KDM_CFG filename |
| 39 | get_gdm_kdm_conf_filename |
| 40 | |
| 41 | # |
| 42 | set_gdm_auto_login() { |
| 43 | # To config these two parameters: |
| 44 | # AutomaticLoginEnable=false/true |
| 45 | # AutomaticLogin= |
| 46 | local inode="$1" |
| 47 | local iauto_login_id="$2" |
| 48 | if [ ! -f "$inode/$GDM_CFG" ]; then |
| 49 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 50 | echo "GDM config in $inode NOT found, assume it's DRBL SSI mode!" |
| 51 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 52 | return 1 |
| 53 | fi |
| 54 | # disable other types login (timed login) if exists |
| 55 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginEnable=.*/TimedLoginEnable=false/" $inode/$GDM_CFG |
| 56 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLogin=.*/TimedLogin=/" $inode/$GDM_CFG |
| 57 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginDelay=.*/TimedLoginDelay=/" $inode/$GDM_CFG |
| 58 | |
| 59 | # enable autologin |
| 60 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)" |
| 61 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 62 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 63 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 64 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$GDM_CFG | grep -i "^AutomaticLoginEnable=")" ]; then |
| 65 | sub_cmd="if ($begin_line..$end_line) {s/^AutomaticLoginEnable=.*/AutomaticLoginEnable=true/}" |
| 66 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 67 | else |
| 68 | # insert 1 blank line |
| 69 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 70 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 71 | # replace the one we want in the added blank line |
| 72 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/AutomaticLoginEnable=true/gi}" |
| 73 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 74 | fi |
| 75 | # put the autologin id |
| 76 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)" |
| 77 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 78 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 79 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 80 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$GDM_CFG | grep -i "^AutomaticLogin=")" ]; then |
| 81 | sub_cmd="if ($begin_line..$end_line) {s/^AutomaticLogin=.*/AutomaticLogin=$iauto_login_id/}" |
| 82 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 83 | else |
| 84 | # insert 1 blank line |
| 85 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 86 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 87 | # replace the one we want in the added blank line |
| 88 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/AutomaticLogin=$iauto_login_id/gi}" |
| 89 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 90 | fi |
| 91 | } # end of set_gdm_auto_login |
| 92 | # |
| 93 | set_gdm_timed_login() { |
| 94 | local inode="$1" |
| 95 | local iauto_login_id="$2" |
| 96 | local tlogin_time="$3" |
| 97 | if [ ! -f $inode/$GDM_CFG ]; then |
| 98 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 99 | echo "$inode/$GDM_CFG is NOT found!!! Assume it's DRBL SSI mode!" |
| 100 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 101 | return 1 |
| 102 | fi |
| 103 | # set the timed login time |
| 104 | [ -z "$tlogin_time" ] && tlogin_time="$TIMED_GDM_TIME_DEFAULT" |
| 105 | # disable other types login (auto login) if they exists |
| 106 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLoginEnable=.*/AutomaticLoginEnable=false/" $inode/$GDM_CFG |
| 107 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLogin=.*/AutomaticLogin=/" $inode/$GDM_CFG |
| 108 | |
| 109 | # enable timed login |
| 110 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)" |
| 111 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 112 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 113 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 114 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$GDM_CFG | grep -i "^TimedLoginEnable=")" ]; then |
| 115 | sub_cmd="if ($begin_line..$end_line) {s/^TimedLoginEnable=.*/TimedLoginEnable=true/}" |
| 116 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 117 | else |
| 118 | # insert 1 blank line |
| 119 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 120 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 121 | # replace the one we want in the added blank line |
| 122 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLoginEnable=true/gi}" |
| 123 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 124 | fi |
| 125 | # put the timedlogin delay time |
| 126 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)" |
| 127 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 128 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 129 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 130 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$GDM_CFG | grep -i "^TimedLoginDelay=")" ]; then |
| 131 | sub_cmd="if ($begin_line..$end_line) {s/^TimedLoginDelay=.*/TimedLoginDelay=$tlogin_time/}" |
| 132 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 133 | else |
| 134 | # insert 1 blank line |
| 135 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 136 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 137 | # replace the one we want in the added blank line |
| 138 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLoginDelay=$tlogin_time/gi}" |
| 139 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 140 | fi |
| 141 | # put the timedlogin id |
| 142 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)" |
| 143 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 144 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 145 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 146 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$GDM_CFG | grep -i "^TimedLogin=")" ]; then |
| 147 | sub_cmd="if ($begin_line..$end_line) {s/^TimedLogin=.*/TimedLogin=$iauto_login_id/}" |
| 148 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 149 | else |
| 150 | # insert 1 blank line |
| 151 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 152 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 153 | # replace the one we want in the added blank line |
| 154 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLogin=$iauto_login_id/gi}" |
| 155 | perl -pi -e "$sub_cmd" $inode/$GDM_CFG |
| 156 | fi |
| 157 | } # end of set_gdm_timed_login |
| 158 | # |
| 159 | set_gdm_normal_login() { |
| 160 | local inode="$1" |
| 161 | if [ ! -f $inode/$GDM_CFG ]; then |
| 162 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 163 | echo "$inode/$GDM_CFG is NOT found!!! Assume it's DRBL SSI mode!" |
| 164 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 165 | return 1 |
| 166 | fi |
| 167 | # disable auto and timed login, then it will be normal login since this is the default setting. |
| 168 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLoginEnable=.*/AutomaticLoginEnable=false/" $inode/$GDM_CFG |
| 169 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLogin=.*/AutomaticLogin=/" $inode/$GDM_CFG |
| 170 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginEnable=.*/TimedLoginEnable=false/" $inode/$GDM_CFG |
| 171 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLogin=.*/TimedLogin=/" $inode/$GDM_CFG |
| 172 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginDelay=.*/TimedLoginDelay=/" $inode/$GDM_CFG |
| 173 | } # end of set_gdm_normal_login |
| 174 | # |
| 175 | set_lightdm_auto_login() { |
| 176 | # To config these two parameters: |
| 177 | # autologin-user=<YOUR USER> |
| 178 | # autologin-user-timeout=0 |
| 179 | local inode="$1" |
| 180 | local iauto_login_id="$2" |
| 181 | if [ ! -f "$inode/$LIGHTDM_CFG" -a \ |
| 182 | -d "$inode/etc/lightdm/lightdm.conf.d" ]; then |
| 183 | # For Ubuntu 13.10, lightdm 1.8.4 has different initial configration file. |
| 184 | # "/etc/lightdm/lightdm.conf" does not exist in the initial installation. |
| 185 | # While it will exist when a user configures that in the GUI. |
| 186 | # We create one here. |
| 187 | echo "[SeatDefaults]" > $inode/$LIGHTDM_CFG |
| 188 | fi |
| 189 | if [ ! -f "$inode/$LIGHTDM_CFG" ]; then |
| 190 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 191 | echo "LightDM config in $inode NOT found, assume it's DRBL SSI mode!" |
| 192 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 193 | return 1 |
| 194 | fi |
| 195 | # disable other types login (timed login) if exists |
| 196 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user-timeout=.*/autologin-user-timeout=0/" $inode/$LIGHTDM_CFG |
| 197 | |
| 198 | # put the autologin id |
| 199 | lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)" |
| 200 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 201 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 202 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 203 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grep -i "^autologin-user=")" ]; then |
| 204 | sub_cmd="if ($begin_line..$end_line) {s/^autologin-user=.*/autologin-user=$iauto_login_id/}" |
| 205 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 206 | else |
| 207 | # insert 1 blank line |
| 208 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 209 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 210 | # replace the one we want in the added blank line |
| 211 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/autologin-user=$iauto_login_id/gi}" |
| 212 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 213 | fi |
| 214 | } # end of set_lightdm_auto_login |
| 215 | # |
| 216 | set_lightdm_timed_login() { |
| 217 | # //NOTE// Due to a bug, this /autologin-user-timeout=* actually won't work on Ubuntu 11.10 and 12.04. |
| 218 | # Ref: https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/902852 |
| 219 | local inode="$1" |
| 220 | local iauto_login_id="$2" |
| 221 | local tlogin_time="$3" |
| 222 | if [ ! -f "$inode/$LIGHTDM_CFG" -a \ |
| 223 | -d "$inode/etc/lightdm/lightdm.conf.d" ]; then |
| 224 | # For Ubuntu 13.10, lightdm 1.8.4 has different initial configration file. |
| 225 | # "/etc/lightdm/lightdm.conf" does not exist in the initial installation. |
| 226 | # While it will exist when a user configures that in the GUI. |
| 227 | # We create one here. |
| 228 | echo "[SeatDefaults]" > $inode/$LIGHTDM_CFG |
| 229 | fi |
| 230 | if [ ! -f $inode/$LIGHTDM_CFG ]; then |
| 231 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 232 | echo "$inode/$LIGHTDM_CFG is NOT found!!! Assume it's DRBL SSI mode!" |
| 233 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 234 | return 1 |
| 235 | fi |
| 236 | # set the timed login time |
| 237 | [ -z "$tlogin_time" ] && tlogin_time="$TIMED_LIGHTDM_TIME_DEFAULT" |
| 238 | |
| 239 | # put the timedlogin delay time |
| 240 | lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)" |
| 241 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 242 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 243 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 244 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grep -i "^autologin-user-timeout=")" ]; then |
| 245 | sub_cmd="if ($begin_line..$end_line) {s/^autologin-user-timeout=.*/autologin-user-timeout=$tlogin_time/}" |
| 246 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 247 | else |
| 248 | # insert 1 blank line |
| 249 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 250 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 251 | # replace the one we want in the added blank line |
| 252 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/autologin-user-timeout=$tlogin_time/gi}" |
| 253 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 254 | fi |
| 255 | # put the timedlogin id |
| 256 | lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)" |
| 257 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 258 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 259 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 260 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grep -i "^autologin-user=")" ]; then |
| 261 | sub_cmd="if ($begin_line..$end_line) {s/^autologin-user=.*/autologin-user=$iauto_login_id/}" |
| 262 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 263 | else |
| 264 | # insert 1 blank line |
| 265 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 266 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 267 | # replace the one we want in the added blank line |
| 268 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/autologin-user=$iauto_login_id/gi}" |
| 269 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 270 | fi |
| 271 | # Append greeter-show-manual-login=true |
| 272 | tune_lightdm_manual_login $inode true |
| 273 | } # end of set_lightdm_timed_login |
| 274 | # |
| 275 | tune_lightdm_manual_login() { |
| 276 | local inode="$1" # Path to $LIGHTDM_CFG |
| 277 | local manual_login_mode="$2" # true or false |
| 278 | # To config greeter-show-manual-login=true |
| 279 | if [ ! -f "$inode/$LIGHTDM_CFG" ]; then |
| 280 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 281 | echo "LightDM config in $inode NOT found, assume it's DRBL SSI mode!" |
| 282 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 283 | return 1 |
| 284 | fi |
| 285 | |
| 286 | # put the greeter-show-manual-login |
| 287 | end_line_of_file="$(LC_ALL=C wc -l $inode/$LIGHTDM_CFG | awk -F" " '{print $1}')" |
| 288 | lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)" |
| 289 | # In Xenial, use [Seat:*] to replace with [SeatDefaults]. That's the reason to get "end_line_of_file first". By Ceasar |
| 290 | if [ "$end_line_of_file" = "$(echo $lines | awk -F" " '{print $1}')" ]; then |
| 291 | lines="$(get_block_line_in_gdm_kdm 'Seat:\*' $inode/$LIGHTDM_CFG)" |
| 292 | fi |
| 293 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 294 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 295 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 296 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grep -i "^greeter-show-manual-login=")" ]; then |
| 297 | sub_cmd="if ($begin_line..$end_line) {s/^greeter-show-manual-login=.*/greeter-show-manual-login=$manual_login_mode/}" |
| 298 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 299 | else |
| 300 | # insert 1 blank line |
| 301 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 302 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 303 | # replace the one we want in the added blank line |
| 304 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/greeter-show-manual-login=$manual_login_mode/gi}" |
| 305 | perl -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG |
| 306 | fi |
| 307 | } # end of tune_lightdm_manual_login |
| 308 | # |
| 309 | set_lightdm_normal_login() { |
| 310 | local inode="$1" |
| 311 | if [ ! -f "$inode/$LIGHTDM_CFG" -a \ |
| 312 | -d "$inode/etc/lightdm/lightdm.conf.d" ]; then |
| 313 | # For Ubuntu 13.10, lightdm 1.8.4 has different initial configration file. |
| 314 | # "/etc/lightdm/lightdm.conf" does not exist in the initial installation. |
| 315 | # While it will exist when a user configures that in the GUI. |
| 316 | # We create one here. |
| 317 | echo "[SeatDefaults]" > $inode/$LIGHTDM_CFG |
| 318 | fi |
| 319 | if [ ! -f $inode/$LIGHTDM_CFG ]; then |
| 320 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 321 | echo "$inode/$LIGHTDM_CFG is NOT found!!! Assume it's DRBL SSI mode!" |
| 322 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 323 | return 1 |
| 324 | fi |
| 325 | # disable auto and timed login, then it will be normal login since this is the default setting. |
| 326 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user=.*/#autologin-user=/" $inode/$LIGHTDM_CFG |
| 327 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user-timeout=.*/#autologin-user-timeout=/" $inode/$LIGHTDM_CFG |
| 328 | # Append greeter-show-manual-login=true |
| 329 | tune_lightdm_manual_login $inode true |
| 330 | } # end of set_lightdm_normal_login |
| 331 | # |
| 332 | set_mdm_auto_login() { |
| 333 | local inode="$1" |
| 334 | local iauto_login_id="$2" |
| 335 | if [ ! -f "$inode/$MDM_CFG" ]; then |
| 336 | echo "[daemon]" > $inode/$MDM_CFG |
| 337 | fi |
| 338 | if [ ! -f "$inode/$MDM_CFG" ]; then |
| 339 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 340 | echo "LightDM config in $inode NOT found, assume it's DRBL SSI mode!" |
| 341 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 342 | return 1 |
| 343 | fi |
| 344 | # disable other types login (timed login) if exists |
| 345 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginEnable=.*/TimedLoginEnable=false/" $inode/$MDM_CFG |
| 346 | |
| 347 | # put the autologin id |
| 348 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$MDM_CFG)" |
| 349 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 350 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 351 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 352 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$MDM_CFG | grep -i "^AutomaticLogin=")" ]; then |
| 353 | sub_cmd="if ($begin_line..$end_line) {s/^AutomaticLogin=.*/AutomaticLogin=$iauto_login_id/}" |
| 354 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 355 | else |
| 356 | # insert 2 blank line |
| 357 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n\n/gi}" |
| 358 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 359 | # replace the one we want in the added blank line |
| 360 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/AutomaticLogin=$iauto_login_id/gi}" |
| 361 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 362 | sub_cmd="if ($((end_line+2))..$((end_line+2))) {s/^$/AutomaticLoginEnable=true/gi}" |
| 363 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 364 | |
| 365 | fi |
| 366 | } # end of set_mdm_auto_login |
| 367 | # |
| 368 | set_mdm_timed_login() { |
| 369 | local inode="$1" |
| 370 | local iauto_login_id="$2" |
| 371 | local tlogin_time="$3" |
| 372 | if [ ! -f "$inode/$MDM_CFG" ]; then |
| 373 | echo "[daemon]" > $inode/$MDM_CFG |
| 374 | fi |
| 375 | if [ ! -f $inode/$MDM_CFG ]; then |
| 376 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 377 | echo "$inode/$MDM_CFG is NOT found!!! Assume it's DRBL SSI mode!" |
| 378 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 379 | return 1 |
| 380 | fi |
| 381 | |
| 382 | # disable other types login (timed login) if exists |
| 383 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLoginEnable=.*/AutomaticLoginEnable=false/" $inode/$MDM_CFG |
| 384 | |
| 385 | # set the timed login time |
| 386 | [ -z "$tlogin_time" ] && tlogin_time="$TIMED_LIGHTDM_TIME_DEFAULT" |
| 387 | |
| 388 | # put the timedlogin delay time |
| 389 | lines="$(get_block_line_in_gdm_kdm daemon $inode/$MDM_CFG)" |
| 390 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 391 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 392 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 393 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$MDM_CFG | grep -i "^TimedLoginDelay=")" ]; then |
| 394 | sub_cmd="if ($begin_line..$end_line) {s/^TimedLoginDelay=.*/TimedLoginDelay=$tlogin_time/}" |
| 395 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 396 | else |
| 397 | # insert 1 blank line |
| 398 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 399 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 400 | # replace the one we want in the added blank line |
| 401 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLoginDelay=$tlogin_time/gi}" |
| 402 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 403 | fi |
| 404 | # put the timedlogin id |
| 405 | lines="$(get_block_line_in_gdm_kdm deamon $inode/$MDM_CFG)" |
| 406 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 407 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 408 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 409 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$MDM_CFG | grep -i "^TimedLogin=")" ]; then |
| 410 | sub_cmd="if ($begin_line..$end_line) {s/^TimedLogin=.*/TimedLogin=$iauto_login_id/}" |
| 411 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 412 | else |
| 413 | # insert 2 blank line |
| 414 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n\n/gi}" |
| 415 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 416 | # replace the one we want in the added blank line |
| 417 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLogin=$iauto_login_id/gi}" |
| 418 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 419 | sub_cmd="if ($((end_line+2))..$((end_line+2))) {s/^$/TimedLoginEnable=true/gi}" |
| 420 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 421 | fi |
| 422 | # Append greeter-show-manual-login=true |
| 423 | tune_mdm_manual_login $inode true |
| 424 | } # end of set_mdm_timed_login |
| 425 | # |
| 426 | tune_mdm_manual_login() { |
| 427 | local inode="$1" # Path to $LIGHTDM_CFG |
| 428 | local manual_login_mode="$2" # true or false |
| 429 | # To config greeter-show-manual-login=true |
| 430 | if [ ! -f "$inode/$LIGHTDM_CFG" ]; then |
| 431 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 432 | echo "LightDM config in $inode NOT found, assume it's DRBL SSI mode!" |
| 433 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 434 | return 1 |
| 435 | fi |
| 436 | |
| 437 | # put the greeter-show-manual-login |
| 438 | lines="$(get_block_line_in_gdm_kdm greeter $inode/$MDM_CFG)" |
| 439 | begin_line=$(echo $lines | awk -F" " '{print $1}') |
| 440 | end_line=$(echo $lines | awk -F" " '{print $2}') |
| 441 | chk_cmd="if ($begin_line..$end_line) {print}" |
| 442 | if [ -n "$(perl -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grep -i "^greeter-show-manual-login=")" ]; then |
| 443 | sub_cmd="if ($begin_line..$end_line) {s/^greeter-show-manual-login=.*/greeter-show-manual-login=$manual_login_mode/}" |
| 444 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 445 | else |
| 446 | # insert 1 blank line |
| 447 | sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}" |
| 448 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 449 | # replace the one we want in the added blank line |
| 450 | sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/greeter-show-manual-login=$manual_login_mode/gi}" |
| 451 | perl -pi -e "$sub_cmd" $inode/$MDM_CFG |
| 452 | fi |
| 453 | } # end of tune_mdm_manual_login |
| 454 | # |
| 455 | set_mdm_normal_login() { |
| 456 | local inode="$1" |
| 457 | if [ ! -f "$inode/$LIGHTDM_CFG" -a \ |
| 458 | -d "$inode/etc/lightdm/lightdm.conf.d" ]; then |
| 459 | echo "[SeatDefaults]" > $inode/$LIGHTDM_CFG |
| 460 | fi |
| 461 | if [ ! -f $inode/$LIGHTDM_CFG ]; then |
| 462 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 463 | echo "$inode/$LIGHTDM_CFG is NOT found!!! Assume it's DRBL SSI mode!" |
| 464 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 465 | return 1 |
| 466 | fi |
| 467 | # disable auto and timed login, then it will be normal login since this is the default setting. |
| 468 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user=.*/#autologin-user=/" $inode/$LIGHTDM_CFG |
| 469 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user-timeout=.*/#autologin-user-timeout=/" $inode/$LIGHTDM_CFG |
| 470 | # Append greeter-show-manual-login=true |
| 471 | tune_mdm_manual_login $inode true |
| 472 | } # end of set_mdm_normal_login |
| 473 | set_kdm_auto_login() { |
| 474 | local inode="$1" |
| 475 | if [ ! -f "$inode/$KDM_CFG" ]; then |
| 476 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 477 | echo "KDM config in $inode NOT found!!! Assume it's DRBL SSI mode!" |
| 478 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 479 | return 1 |
| 480 | fi |
| 481 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutoLoginEnable=.*/AutoLoginEnable=true/" $inode/$KDM_CFG |
| 482 | perl -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutoLoginUser=.*/AutoLoginUser=$auto_login_id/" $inode/$KDM_CFG |
| 483 | } # end of set_kdm_auto_login |
| 484 | # |
| 485 | create_autologin_account() { |
| 486 | # $create_account, $auto_login_id and $echo_no_digit_0_1 are global variables |
| 487 | local ihost="$1" |
| 488 | local shell_opt |
| 489 | get_autologin_account $ihost |
| 490 | # auto_login_id is got from get_autologin_account |
| 491 | [ -z "$auto_login_id" ] && echo "Unable to get $ip client's hostname! Skip this one!" && return 1 |
| 492 | if ! grep -q -E "^$auto_login_id:" /etc/passwd ; then |
| 493 | # account $auto_login_id does not exists, create it. |
| 494 | create_account=1 |
| 495 | # If /bin/bash is found, we try to se /bin/bash as default shell. |
| 496 | shell_opt="" |
| 497 | [ -e /bin/bash ] && shell_opt="-s /bin/bash" |
| 498 | echo -n "Creating account $auto_login_id... " |
| 499 | useradd -m $auto_login_id $shell_opt |
| 500 | fi |
| 501 | |
| 502 | # set password when accounts are created (at that time the passwords are empty) or when password_opt is assigned |
| 503 | if [ "$create_account" = "1" -o -n "$password_opt" ]; then |
| 504 | # clean the old file |
| 505 | clean_old_auto_login_id_passwd_file $AUTO_LOGIN_ID_PASSWD $auto_login_id |
| 506 | # set the passwd |
| 507 | set_client_autologin_passwd=1 |
| 508 | case "$password_opt" in |
| 509 | [0-9]|"") |
| 510 | echo -n "The password_opt is set as \"$password_opt\". " |
| 511 | # echo the message $PWD_NO_0_1_MSG in the file $AUTO_LOGIN_ID_PASSWD |
| 512 | # if it does not exist. |
| 513 | if [ -z "`grep $PWD_NO_0_1_MSG $AUTO_LOGIN_ID_PASSWD 2>/dev/null`" ]; then |
| 514 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 515 | echo $PWD_NO_0_1_MSG | tee -a $AUTO_LOGIN_ID_PASSWD |
| 516 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 517 | fi |
| 518 | echo_no_digit_0_1=1 |
| 519 | # get one digit, so it must be the length of password |
| 520 | # or it's empty, we set it as $password_opt_default |
| 521 | if [ -z "$password_opt" ]; then |
| 522 | echo -n "You did NOT set the length of password, set it as $PASSWD_LENGTH_DEFAULT. " |
| 523 | password_opt="$PASSWD_LENGTH_DEFAULT" |
| 524 | fi |
| 525 | echo -n "Generating random password from password length $password_opt... " |
| 526 | make_random_password $password_opt |
| 527 | passwd_now=$random_password |
| 528 | echo "$auto_login_id:$passwd_now" | chpasswd |
| 529 | ;; |
| 530 | *) |
| 531 | echo -n "Set password from input..." |
| 532 | passwd_now="$password_opt" |
| 533 | echo "$auto_login_id:$passwd_now" | chpasswd |
| 534 | esac |
| 535 | echo "$auto_login_id $passwd_now" >> $AUTO_LOGIN_ID_PASSWD |
| 536 | fi |
| 537 | } # end of create_autologin_account |
| 538 | # |
| 539 | clean_old_auto_login_id_passwd_file() { |
| 540 | local local_autologin_id_pwd_file="$1" |
| 541 | local local_auto_login_id="$2" |
| 542 | [ -z "$local_auto_login_id" ] && echo "Unable to get auto login id! Skip this one!" && return 1 |
| 543 | # rename the old file, local_auto_login_id is a tag so that we will rename it just onece, not for every accounts. |
| 544 | if [ -f "$local_autologin_id_pwd_file" ]; then |
| 545 | if grep -q -E "\<$local_auto_login_id\>" $local_autologin_id_pwd_file; then |
| 546 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 547 | echo "An existing file \"$local_autologin_id_pwd_file\" is found. Rename it as \"$local_autologin_id_pwd_file.drblsave\"" |
| 548 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 549 | mv -f $local_autologin_id_pwd_file ${local_autologin_id_pwd_file}.drblsave |
| 550 | fi |
| 551 | fi |
| 552 | } # end of clean_old_auto_login_id_passwd_file |
| 553 | # |
| 554 | output_result_and_update_yp() { |
| 555 | # $create_account, $no_nis_update and $set_client_autologin_passwd are global variables |
| 556 | if [ "$set_client_autologin_passwd" = "1" ]; then |
| 557 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 558 | echo $msg_created_autologin_ID_passwd_file |
| 559 | #echo $PWD_NO_0_1_MSG | tee -a $AUTO_LOGIN_ID_PASSWD |
| 560 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 561 | # update the NIS |
| 562 | [ "$no_nis_update" != "on" ] && make -C /var/yp |
| 563 | fi |
| 564 | } # end of output_result_and_update_yp |
| 565 | |
| 566 | ############## |
| 567 | ### MAIN ### |
| 568 | ############## |
| 569 | # set the flag for create account and echo prompt |
| 570 | # $create_account, $auto_login_id, $no_nis_update, $set_client_autologin_passwd and $echo_no_digit_0_1 are global variables |
| 571 | create_account=0 |
| 572 | echo_no_digit_0_1=0 |
| 573 | set_client_autologin_passwd=0 |
| 574 | |
| 575 | # If clonezilla box or drbl-ssi mode |
| 576 | [ -f /etc/drbl/drbl_deploy.conf ] && . /etc/drbl/drbl_deploy.conf |
| 577 | if [ "$clonezilla_mode" = "clonezilla_box_mode" -o "$drbl_mode" = "drbl_ssi_mode" ]; then |
| 578 | gen_ssi="yes" |
| 579 | else |
| 580 | gen_ssi="no" |
| 581 | fi |
| 582 | |
| 583 | while [ $# -gt 0 ]; do |
| 584 | case "$1" in |
| 585 | -n|--normal) |
| 586 | shift; login_dm_mode="normal_login" |
| 587 | ;; |
| 588 | -a|--auto) |
| 589 | shift; login_dm_mode="auto_login" |
| 590 | ;; |
| 591 | -t|--timed) |
| 592 | shift; login_dm_mode="timed_login" |
| 593 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
| 594 | # skip the -xx option, in case |
| 595 | timed_login_time="$1" |
| 596 | shift |
| 597 | fi |
| 598 | ;; |
| 599 | -l|--language) |
| 600 | shift |
| 601 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
| 602 | # skip the -xx option, in case |
| 603 | specified_lang="$1" |
| 604 | shift |
| 605 | fi |
| 606 | ;; |
| 607 | -h|--host) |
| 608 | shift |
| 609 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
| 610 | # skip the -xx option, in case |
| 611 | specified_host="$1" |
| 612 | shift |
| 613 | fi |
| 614 | ;; |
| 615 | -g|--no-gen-ssi) |
| 616 | gen_ssi="no" |
| 617 | shift;; |
| 618 | -v|--verbose) |
| 619 | shift; verbose="on" |
| 620 | ;; |
| 621 | -u|--no_nis_update) |
| 622 | shift; no_nis_update="on" |
| 623 | ;; |
| 624 | -p|--password_opt) |
| 625 | shift |
| 626 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
| 627 | # skip the -xx option, in case |
| 628 | password_opt="$1" |
| 629 | shift |
| 630 | fi |
| 631 | ;; |
| 632 | -*) echo "${0}: ${1}: invalid option" >&2 |
| 633 | usage >& 2 |
| 634 | exit 2 ;; |
| 635 | *) break ;; |
| 636 | esac |
| 637 | done |
| 638 | |
| 639 | # |
| 640 | ask_and_load_lang_set $specified_lang |
| 641 | |
| 642 | # check if the mode is set or net |
| 643 | [ -z "$login_dm_mode" ] && usage && exit 1 |
| 644 | |
| 645 | # |
| 646 | if [ -n "$specified_host" ]; then |
| 647 | [ ! -d "$drblroot/$specified_host" ] && echo "Can NOT find DRBL client $specified_host (i.e. no $drblroot/$specified_host)! Assume it's DRBL SSI client." |
| 648 | [ -n "$verbose" ] && echo "specified_host: $specified_host" |
| 649 | fi |
| 650 | |
| 651 | # set the login option for GDM |
| 652 | [ -n "$verbose" ] && echo -n "The GDM login option: $login_dm_mode..." |
| 653 | |
| 654 | # set the host to be processed |
| 655 | # host_list is the IP address of client, like 192.168.1.1... |
| 656 | host_list="" |
| 657 | if [ -n "$specified_host" ]; then |
| 658 | # set the host path |
| 659 | host_list=$drblroot/$specified_host |
| 660 | else |
| 661 | # withoud specified_host, it must be all clients, append each one to $host_list |
| 662 | for ihost in `get-client-ip-list`; do |
| 663 | host_list="$host_list $drblroot/$ihost" |
| 664 | done |
| 665 | fi |
| 666 | |
| 667 | RC="" |
| 668 | preferred="$(drbl-check-dm)" |
| 669 | RC=$? |
| 670 | |
| 671 | [ $RC -eq 0 ] && echo "Display manager:\"$preferred\"..." |
| 672 | |
| 673 | if [ -z "$preferred" ]; then |
| 674 | echo "No display manager was found!" |
| 675 | echo "Skip changing client's login mode of graphical interface." |
| 676 | exit 3 |
| 677 | fi |
| 678 | |
| 679 | # |
| 680 | case "$preferred" in |
| 681 | gdm*) |
| 682 | for ihost in $host_list; do |
| 683 | echo -n "Setting node `basename $ihost` as $login_dm_mode... " |
| 684 | case "$login_dm_mode" in |
| 685 | "auto_login"|"timed_login") |
| 686 | # create auto login account if necessary |
| 687 | create_autologin_account $ihost |
| 688 | # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only |
| 689 | [ -f "$AUTO_LOGIN_ID_PASSWD" ] && chmod 600 $AUTO_LOGIN_ID_PASSWD |
| 690 | case "$login_dm_mode" in |
| 691 | "auto_login") |
| 692 | set_gdm_auto_login $ihost $auto_login_id |
| 693 | ;; |
| 694 | "timed_login") |
| 695 | set_gdm_timed_login $ihost $auto_login_id $timed_login_time |
| 696 | ;; |
| 697 | esac |
| 698 | echo "done!" |
| 699 | ;; |
| 700 | "normal_login") |
| 701 | set_gdm_normal_login $ihost |
| 702 | echo "done!" |
| 703 | ;; |
| 704 | esac |
| 705 | done |
| 706 | # output result and update yp |
| 707 | output_result_and_update_yp |
| 708 | ;; |
| 709 | kdm|mdkkdm) |
| 710 | # No timed_login for KDE... only auto_login or nornam_login |
| 711 | [ "$login_dm_mode" = "timed_login" ] && echo "No timed login for KDE... only auto login or normal login, so set it as auto login..." |
| 712 | for ihost in $host_list; do |
| 713 | echo -n "Setting node `basename $ihost` as $login_dm_mode... " |
| 714 | case "$login_dm_mode" in |
| 715 | "auto_login"|"timed_login") |
| 716 | # create auto login account if necessary |
| 717 | create_autologin_account $ihost |
| 718 | # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only |
| 719 | [ -f "$AUTO_LOGIN_ID_PASSWD" ] && chmod 600 $AUTO_LOGIN_ID_PASSWD |
| 720 | set_kdm_auto_login $ihost |
| 721 | echo "done!" |
| 722 | ;; |
| 723 | "normal_login") |
| 724 | [ -f "$ihost/$SYSCONF_PATH/autologin" ] && rm -f $ihost/$SYSCONF_PATH/autologin |
| 725 | echo "done!" |
| 726 | ;; |
| 727 | esac |
| 728 | done |
| 729 | # output result and update yp |
| 730 | output_result_and_update_yp |
| 731 | ;; |
| 732 | lightdm) |
| 733 | for ihost in $host_list; do |
| 734 | echo -n "Setting node `basename $ihost` as $login_dm_mode... " |
| 735 | case "$login_dm_mode" in |
| 736 | "auto_login"|"timed_login") |
| 737 | # create auto login account if necessary |
| 738 | create_autologin_account $ihost |
| 739 | # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only |
| 740 | [ -f "$AUTO_LOGIN_ID_PASSWD" ] && chmod 600 $AUTO_LOGIN_ID_PASSWD |
| 741 | case "$login_dm_mode" in |
| 742 | "auto_login") |
| 743 | set_lightdm_auto_login $ihost $auto_login_id |
| 744 | ;; |
| 745 | "timed_login") |
| 746 | set_lightdm_timed_login $ihost $auto_login_id $timed_login_time |
| 747 | ;; |
| 748 | esac |
| 749 | echo "done!" |
| 750 | ;; |
| 751 | "normal_login") |
| 752 | set_lightdm_normal_login $ihost |
| 753 | echo "done!" |
| 754 | ;; |
| 755 | esac |
| 756 | done |
| 757 | # output result and update yp |
| 758 | output_result_and_update_yp |
| 759 | ;; |
| 760 | mdm) |
| 761 | for ihost in $host_list; do |
| 762 | echo -n "Setting node `basename $ihost` as $login_dm_mode... " |
| 763 | case "$login_dm_mode" in |
| 764 | "auto_login"|"timed_login") |
| 765 | # create auto login account if necessary |
| 766 | create_autologin_account $ihost |
| 767 | # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only |
| 768 | [ -f "$AUTO_LOGIN_ID_PASSWD" ] && chmod 600 $AUTO_LOGIN_ID_PASSWD |
| 769 | case "$login_dm_mode" in |
| 770 | "auto_login") |
| 771 | set_mdm_auto_login $ihost $auto_login_id |
| 772 | ;; |
| 773 | "timed_login") |
| 774 | set_mdm_timed_login $ihost $auto_login_id $timed_login_time |
| 775 | ;; |
| 776 | esac |
| 777 | echo "done!" |
| 778 | ;; |
| 779 | "normal_login") |
| 780 | set_mdm_normal_login $ihost |
| 781 | echo "done!" |
| 782 | ;; |
| 783 | esac |
| 784 | done |
| 785 | # output result and update yp |
| 786 | output_result_and_update_yp |
| 787 | ;; |
| 788 | *) |
| 789 | [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 790 | echo "Unknown display manager! This display manager \"$preferred\" is not supported by `basename $0`." |
| 791 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 792 | echo "$msg_program_stop" |
| 793 | exit 1 |
| 794 | ;; |
| 795 | esac |
| 796 | |
| 797 | # |
| 798 | if [ "$gen_ssi" = "yes" ]; then |
| 799 | echo "-------------------------------------------------------" |
| 800 | echo "Since some config files are modified in template client, creating template tarball for DRBL SSI..." |
| 801 | drbl-gen-ssi-files |
| 802 | fi |