]> xenbits.xen.org Git - xenclient/build.git/commitdiff
[initscripts] Set password and disable/enable ssh based on installer settings
authorThomas Horsten <thomas.horsten@citrix.com>
Fri, 11 Dec 2009 19:17:10 +0000 (19:17 +0000)
committerThomas Horsten <thomas.horsten@citrix.com>
Fri, 11 Dec 2009 19:17:10 +0000 (19:17 +0000)
package/openssh/S50sshd
target/generic/target_xenclient_skeleton/etc/init.d/S35configuration [new file with mode: 0755]

index e9d39f85e53bc292f79ad8ae3ae6a38f10d5200f..207e630188da4ffc4089a81c5961a6dcfd1e7aa8 100644 (file)
@@ -3,6 +3,9 @@
 # sshd        Starts sshd.
 #
 
+# Only run SSH server if it is enabled
+[ -f /config/ssh_enabled ] || exit 0
+
 # Make sure the ssh-keygen progam exists
 [ -f /usr/bin/ssh-keygen ] || exit 0
 
diff --git a/target/generic/target_xenclient_skeleton/etc/init.d/S35configuration b/target/generic/target_xenclient_skeleton/etc/init.d/S35configuration
new file mode 100755 (executable)
index 0000000..54403a7
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Check for configuration files left by the installer
+
+# Password
+
+CFGDIR=/config/install/data
+UPGRADE_CFGDIR=/config/upgrade/data
+
+umask 077
+
+for a in password.conf ssh.conf; do
+  if [ -f $UPGRADE_CFGDIR/$a ]; then
+    mv -f $UPGRADE_CFGDIR/$a $CFGDIR/$a
+  fi
+done
+
+if [ -f ${CFGDIR}/password.conf ]; then
+  eval `cat ${CFGDIR}/password.conf`
+  awk -F: -v OFS=: "/^root:/ {\$2 = \"${PASSWORD}\"; print } ; !/^root:/ {print}" /etc/shadow > /etc/shadow.new
+  mv -f /etc/shadow.new /etc/shadow
+  mv -f ${CFGDIR}/password.conf ${CFGDIR}/password.conf.DONE
+fi
+
+if [ -f ${CFGDIR}/ssh.conf ]; then
+  eval `cat ${CFGDIR}/ssh.conf`
+  if [ "$SSH_ENABLED" = "true" ]; then
+    touch /config/ssh_enabled
+  else
+    rm -f /config/ssh_enabled
+  fi
+  mv -f ${CFGDIR}/ssh.conf ${CFGDIR}/ssh.conf.DONE
+fi