implement bootparameter rootpw=<pw> to set root password
[grml-autoconfig.git] / autoconfig.functions
index 73cc32e..1571255 100755 (executable)
@@ -1444,6 +1444,31 @@ fi
 }
 # }}}
 
+# {{{ configure root password
+config_rootpw(){
+if checkbootparam 'rootpw' ; then
+   ROOT_PASSWD=''
+   ROOT_PASSWD="$(getbootparam 'rootpw' 2>>$DEBUG)"
+   einfo "Bootoption rootpw found, trying to set password for user root."
+
+   if [ -z "$ROOT_PASSWD" ] ; then
+      ewarn "No password given for user root. Please set one with rootpw=<pw>" ; eend 0
+   else
+      # chpasswd sucks, seriously.
+      if chpasswd --help 2>&1 | grep -q -- '-m,' ; then
+        echo "root:$ROOT_PASSWD" | chpasswd -m
+      else
+        echo "root:$ROOT_PASSWD" | chpasswd
+      fi
+   fi
+
+   eindent
+   ewarn 'Warning: please change the password for user root as soon as possible!'
+   eoutdent
+fi
+}
+# }}}
+
 # {{{ autostart of x11vnc
 config_vnc(){
 
@@ -1836,20 +1861,19 @@ if checkbootparam 'startx' && ! echo "$CMDLINE" | grep -q 'startx.*nostartx' ; t
    else
      einfo "Window manager ${WHITE}${WINDOWMANAGER}${NORMAL} found as bootoption." && eend 0
    fi
-   einfo "Changing to runlevel 5 for starting grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles."
+   einfo "Setting up and invoking grml-x ${WINDOWMANAGER}. Just exit X windows system to get full featured consoles."
    config_userfstab || fstabuser='grml'
  cat>|/etc/init.d/xstartup<<EOF
 #!/bin/sh
-# su - $fstabuser -c 'grml-x "$WINDOWMANAGER"'
-sudo -u $fstabuser -i /usr/bin/grml-x $WINDOWMANAGER >>$DEBUG
+su $fstabuser -c "/usr/bin/grml-x $WINDOWMANAGER"
 EOF
    chmod 755 /etc/init.d/xstartup
 
    # adjust inittab for xstartup
    if grep -q '^6:' /etc/inittab ; then
-      sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /bin/zsh"|' /etc/inittab
+      sed -i 's|^6:.*|6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/bin/zsh-login" >/dev/tty6 2>\&1 </dev/tty6|' /etc/inittab
    else # just append tty6 to inittab if no definition is present:
-      echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /bin/zsh"' >> /etc/inittab
+      echo '6:2345:respawn:/bin/zsh --login -c "/etc/init.d/xstartup ; /usr/bin/zsh-login" >/dev/tty6 2>&1 < /dev/tty6' >> /etc/inittab
    fi
 
    /sbin/telinit q ; eend $?