untabified all init scripts
authorparmentelat <thierry.parmentelat@inria.fr>
Fri, 14 Dec 2018 10:36:16 +0000 (11:36 +0100)
committerparmentelat <thierry.parmentelat@inria.fr>
Fri, 14 Dec 2018 10:36:16 +0000 (11:36 +0100)
initscripts/pl_boot
initscripts/pl_functions
initscripts/pl_hwinit
initscripts/pl_netinit
initscripts/pl_sysinit

index b057701..f0faaf8 100755 (executable)
@@ -114,7 +114,7 @@ while true; do
     if [[ $contact_count != 0 ]]; then
 
         verbose-message "pl_boot: next attempt in 30s, to fetch script from server at $CONNECT_BOOT_SERVER"
-       /bin/sleep 30
+        /bin/sleep 30
     fi
 
     # June 2015 : using --tlsv1 instead of sslv3 that should be available
@@ -189,9 +189,9 @@ while true; do
                     verbose-message "with as much detail as possible."
                 ;;
             esac
-           # in any case display as much info as we can (see pl_functions)
-           verbose-forensics "after curl"
-           # retry
+            # in any case display as much info as we can (see pl_functions)
+            verbose-forensics "after curl"
+            # retry
             continue
         fi
     elif [ -n "$DISCONNECTED_OPERATION" ]; then
index 81c3a77..18e6952 100644 (file)
@@ -15,9 +15,9 @@ function verbose-file() {
     file=$1; shift
     echo "$file"
     if ! [ -f "$file" ]; then
-       verbose-message "!!!!!!!!!! missing $file"
+        verbose-message "!!!!!!!!!! missing $file"
     else
-       verbose-run cat $file
+        verbose-run cat $file
     fi
 }
 
@@ -26,10 +26,10 @@ function verbose-file-uncommented-patterns () {
     egrep_pattern=$2; shift
 
     if ! [ -f "$file" ]; then
-       verbose-message "!!!!!!!!!! missing $file"
+        verbose-message "!!!!!!!!!! missing $file"
     else
-       echo '---------- egrep $egrep_pattern' $file
-       grep -v '^#' $file | egrep "$egrep_pattern"
+        echo '---------- egrep $egrep_pattern' $file
+        grep -v '^#' $file | egrep "$egrep_pattern"
     fi
 }
     
@@ -43,7 +43,7 @@ function verbose-forensics () {
     # XXX : need to check for a running udev
 
     for file in /etc/resolv.conf /run/resolvconf/resolv.conf /etc/sysconfig/network-scripts/ifcfg-eth*; do 
-       verbose-file $file
+        verbose-file $file
     done
     verbose-message Configured interfaces
     verbose-run ls -l /sys/class/net/
@@ -61,14 +61,14 @@ function verbose-forensics () {
     # try to resolve this hostname as that's the one used for ntp
     dnss=$(grep '^nameserver' /etc/resolv.conf 2>/dev/null | awk '{print $2;}')
     if [ -z "$dnss" ] ; then
-       # not too helpful, but..
-       verbose-message "!!!" No server found in /etc/resolv.conf - Resolving hostname at the google public DNS
-       verbose-run host -W 4 pool.ntp.org 8.8.8.8
+        # not too helpful, but..
+        verbose-message "!!!" No server found in /etc/resolv.conf - Resolving hostname at the google public DNS
+        verbose-run host -W 4 pool.ntp.org 8.8.8.8
     else
-       for dns in $dnss; do
-           verbose-message Resolving hostname at $dns
-           verbose-run host -W 4 pool.ntp.org $dns
-       done
+        for dns in $dnss; do
+            verbose-message Resolving hostname at $dns
+            verbose-run host -W 4 pool.ntp.org $dns
+        done
     fi
     verbose-file /root/.ssh/authorized_keys
     verbose-file-uncommented-patterns /etc/ssh/sshd_config 'Pass|Auth|PAM|Root'
index 8224a9e..7cddccb 100755 (executable)
@@ -37,7 +37,7 @@ def main(argv):
     for blacklist in blacklists:
         blf = "/etc/modprobe.d/{}".format(blacklist)
         if os.path.exists(blf):
-           f = open(blf)
+            f = open(blf)
             for i in f.readlines():
                 if i.startswith("blacklist"):
                     blacklisted_modules.append(i.split()[1])
index 9ebc182..1f55189 100755 (executable)
@@ -75,32 +75,32 @@ function find-node-config() {
     verbose-message "pl_netinit: looking for node configuration file on floppy"
 
     /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES /dev/fd0 \
-       $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
+        $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
     if [[ $? -eq 0 ]]; then
 
         # 1. check for new named file first on the floppy disk
-       if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
-           conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
-           verbose-message "pl_netinit: found node configuration file $conf_file"
-           /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
-           /bin/umount $CONF_DEVICE_MOUNT_POINT
-           return 1
+        if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
+            conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
+            verbose-message "pl_netinit: found node configuration file $conf_file"
+            /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
+            /bin/umount $CONF_DEVICE_MOUNT_POINT
+            return 1
 
         # since we have the floppy mounted already, see if an old file
         # exists there so we don't have to remount the floppy when we need
         # to check for an old file on it (later in the order). if it does
         # just copy it off to a special location
-       elif [ -r "$CONF_DEVICE_MOUNT_POINT/$OLD_NODE_CONF_NAME" ]; then
-           conf_file="$CONF_DEVICE_MOUNT_POINT/$OLD_NODE_CONF_NAME"
-           /bin/cp -f $conf_file $TMP_OLD_FLOPPY_CONF_FILE
-           verbose-message "pl_netinit: found old named configuration file, checking later."
-       else
-           verbose-message "pl_netinit: floppy mounted, but no configuration file."
-       fi
-
-       /bin/umount $CONF_DEVICE_MOUNT_POINT
+        elif [ -r "$CONF_DEVICE_MOUNT_POINT/$OLD_NODE_CONF_NAME" ]; then
+            conf_file="$CONF_DEVICE_MOUNT_POINT/$OLD_NODE_CONF_NAME"
+            /bin/cp -f $conf_file $TMP_OLD_FLOPPY_CONF_FILE
+            verbose-message "pl_netinit: found old named configuration file, checking later."
+        else
+            verbose-message "pl_netinit: floppy mounted, but no configuration file."
+        fi
+
+        /bin/umount $CONF_DEVICE_MOUNT_POINT
     else
-       verbose-message "pl_netinit: no floppy could be mounted, continuing search."
+        verbose-message "pl_netinit: no floppy could be mounted, continuing search."
     fi
 
     # 2. check for a new named file on removable flash devices (those
@@ -115,33 +115,33 @@ function find-node-config() {
     shopt -s nullglob
 
     for device in /sys/block/[hsv]d*; do
-       removable=$(cat $device/removable)
-       if [[ $removable -ne 1 ]]; then
-           continue
-       fi
-
-       partitions=$(/bin/awk "\$4 ~ /$(basename $device)[0-9]*/ { print \$4 }" /proc/partitions)
-       for partition in $partitions ; do
-           check_dev=/dev/$partition
-
-           verbose-message "pl_netinit: looking for node configuration file on device $check_dev"
-           /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES $check_dev \
-               $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
-           if [[ $? -eq 0 ]]; then
-               if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
-                   conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
-                   verbose-message "pl_netinit: found node configuration file $conf_file"
-                   /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
-                   verbose-message "pl_netinit: found configuration"
-                   /bin/umount $CONF_DEVICE_MOUNT_POINT
-                   return 1
-               fi
-
-               verbose-message "pl_netinit: ERROR - not found"
-
-               /bin/umount $CONF_DEVICE_MOUNT_POINT
-           fi
-       done
+        removable=$(cat $device/removable)
+        if [[ $removable -ne 1 ]]; then
+            continue
+        fi
+
+        partitions=$(/bin/awk "\$4 ~ /$(basename $device)[0-9]*/ { print \$4 }" /proc/partitions)
+        for partition in $partitions ; do
+            check_dev=/dev/$partition
+
+            verbose-message "pl_netinit: looking for node configuration file on device $check_dev"
+            /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES $check_dev \
+                $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
+            if [[ $? -eq 0 ]]; then
+                if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
+                    conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
+                    verbose-message "pl_netinit: found node configuration file $conf_file"
+                    /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
+                    verbose-message "pl_netinit: found configuration"
+                    /bin/umount $CONF_DEVICE_MOUNT_POINT
+                    return 1
+                fi
+
+                verbose-message "pl_netinit: ERROR - not found"
+
+                /bin/umount $CONF_DEVICE_MOUNT_POINT
+            fi
+        done
     done
 
     # normal filename expansion setting
@@ -150,10 +150,10 @@ function find-node-config() {
     # 3. see if there is an old file on the floppy disk. if there was,
     # the file $TMP_OLD_FLOPPY_CONF_FILE will be readable.
     if [ -r "$TMP_OLD_FLOPPY_CONF_FILE" ]; then
-       conf_file=$TMP_OLD_FLOPPY_CONF_FILE
-       verbose-message "pl_netinit: found node configuration file $conf_file"
-       /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
-       return 1
+        conf_file=$TMP_OLD_FLOPPY_CONF_FILE
+        verbose-message "pl_netinit: found node configuration file $conf_file"
+        /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
+        return 1
     fi
 
 
@@ -161,9 +161,9 @@ function find-node-config() {
     verbose-message "pl_netinit: looking for network configuration on cd in /usr/boot"
     if [ -r "$CD_NET_CONF_BOOT" ]; then
 
-       verbose-message "pl_netinit: found cd configuration file $CD_NET_BOOT_CONF"
-       /etc/init.d/pl_validateconf < $CD_NET_CONF_BOOT > $USED_NET_CONF
-       return 1
+        verbose-message "pl_netinit: found cd configuration file $CD_NET_BOOT_CONF"
+        /etc/init.d/pl_validateconf < $CD_NET_CONF_BOOT > $USED_NET_CONF
+        return 1
     fi
 
 
@@ -171,9 +171,9 @@ function find-node-config() {
     verbose-message "pl_netinit: looking for network configuration on cd in /usr"
     if [ -r "$CD_NET_CONF_ROOT" ]; then
 
-       verbose-message "pl_netinit: found cd configuration file $CD_NET_CONF_ROOT"
-       /etc/init.d/pl_validateconf < $CD_NET_CONF_ROOT > $USED_NET_CONF
-       return 1
+        verbose-message "pl_netinit: found cd configuration file $CD_NET_CONF_ROOT"
+        /etc/init.d/pl_validateconf < $CD_NET_CONF_ROOT > $USED_NET_CONF
+        return 1
     fi
 
 
@@ -183,10 +183,10 @@ function find-node-config() {
     # can inform the users appropriately.
     verbose-message "pl_netinit: using default network configuration"
     if [ -r "$FALLBACK_NET_CONF" ]; then
-       verbose-message "pl_netinit: found cd default configuration file $FALLBACK_NET_CONF"
-       /etc/init.d/pl_validateconf < $FALLBACK_NET_CONF > $USED_NET_CONF
-       DEFAULT_NET_CONF=1
-       return 1
+        verbose-message "pl_netinit: found cd default configuration file $FALLBACK_NET_CONF"
+        /etc/init.d/pl_validateconf < $FALLBACK_NET_CONF > $USED_NET_CONF
+        DEFAULT_NET_CONF=1
+        return 1
     fi
 
     return 0
@@ -224,7 +224,7 @@ if [[ -n "$IPMI_ADDRESS" ]] ; then
     echo -n "pl_netinit: initializing IPMI: "
     cmd="ipnmac -i $IPMI_ADDRESS"
     if [[ -n "$IPMI_MAC" ]] ; then
-       cmd="$cmd -m $IPMI_MAC"
+        cmd="$cmd -m $IPMI_MAC"
     fi
     echo $cmd
     $cmd
@@ -243,12 +243,12 @@ if [[ -n "$NET_DEVICE" ]]; then
 
     pushd /sys/class/net
     for device in *; do
-       dev_address=$(cat $device/address | tr A-Z a-z)
-       if [ "$device" == "$NET_DEVICE" -o "$dev_address" == "$NET_DEVICE" ]; then
-           ETH_DEVICE=$device
-           verbose-message "pl_netinit: found device $ETH_DEVICE with mac address $dev_address"
-           break
-       fi
+        dev_address=$(cat $device/address | tr A-Z a-z)
+        if [ "$device" == "$NET_DEVICE" -o "$dev_address" == "$NET_DEVICE" ]; then
+            ETH_DEVICE=$device
+            verbose-message "pl_netinit: found device $ETH_DEVICE with mac address $dev_address"
+            break
+        fi
     done
     popd
 fi
@@ -257,9 +257,9 @@ fi
 if [[ -z "$ETH_DEVICE" ]]; then
     pushd /etc/sysconfig/network-scripts > /dev/null
     for conf in ifcfg-*; do
-       egrep -q '^PRIMARY=["'"'"']?[yY1t]' $conf || continue
-       ETH_DEVICE=${conf#ifcfg-}
-       break
+        egrep -q '^PRIMARY=["'"'"']?[yY1t]' $conf || continue
+        ETH_DEVICE=${conf#ifcfg-}
+        break
     done
     popd > /dev/null
 fi
@@ -317,16 +317,16 @@ function pl-netinit-patch-resolv-conf () {
     needed=""
     # missing file : patch needed
     if ! [ -f $file ]; then
-       needed=true
+        needed=true
     # empty file : patch needed
     else
-       contents=$(grep -v '^#' $file)
-       contents=$(echo $contents)
-       [ -z "$contents" ] && needed=true
+        contents=$(grep -v '^#' $file)
+        contents=$(echo $contents)
+        [ -z "$contents" ] && needed=true
     fi
     if [ -z "$needed" ]; then
-       echo pl_netinit has no need to patch $file
-       return
+        echo pl_netinit has no need to patch $file
+        return
     fi
 
     verbose-message "pl_netinit: patching $file"
index 492cc73..dd2f893 100755 (executable)
@@ -36,13 +36,13 @@ function check-initrd() {
         # it is mounted, but we should probably make sure its our boot cd
         # this can be done by making sure the /pl_version file (on initrd)
         # matches /usr/isolinux/pl_version
-       initrd_version=$(/bin/cat /pl_version)
-       cd_version=$(/bin/cat /usr/isolinux/pl_version)
-       if [ "$initrd_version" == "$cd_version" ]; then
-           _mounted=1
-       else
-           verbose-message "pl_sysinit: WARNING pl_version mismatch"
-       fi
+        initrd_version=$(/bin/cat /pl_version)
+        cd_version=$(/bin/cat /usr/isolinux/pl_version)
+        if [ "$initrd_version" == "$cd_version" ]; then
+            _mounted=1
+        else
+            verbose-message "pl_sysinit: WARNING pl_version mismatch"
+        fi
     fi
     return $_mounted
 }
@@ -53,58 +53,58 @@ function check-block-devices() {
     shopt -s nullglob
 
     for device in /sys/block/*; do
-       device=$(/bin/basename $device)
+        device=$(/bin/basename $device)
 
         # skipping any devices that start with md or ra (ram) or lo
-       # (loop) or fd (floppy)
+        # (loop) or fd (floppy)
 
-       start_device=${device:0:2}
-       if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
-           [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
-           continue
-       fi
+        start_device=${device:0:2}
+        if [ "$start_device" == "ra" ] || [ "$start_device" == "md" ] ||
+            [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then
+            continue
+        fi
 
         # If this is a removable (e.g., USB flash) device, then try to
         # look for an ISO image on each of its partitions.
-       if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
-           partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
-           for partition in $partitions ; do
-               echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
-               mkdir -p /tmp/$partition
-               if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
-               # Look for the first ISO image
-                   for iso in /tmp/$partition/*.iso ; do
-                       if /sbin/losetup /dev/loop0 $iso ; then
-                           echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
-                           device="loop0"
-                           break
-                       fi
-                   done
-                   if [ "$device" != "loop0" ] ; then
-                       /bin/umount /tmp/$partition 2>&1 > /dev/null
-                   fi
-               fi
-           done
-       fi
-       
-       verbose-message "pl_sysinit: checking $device for /usr contents"
-       /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
-       if [ $? -eq 0 ]; then
-       # it mounted, but we should probably make sure its our boot cd
-       # this can be done by making sure the /pl_version file (on initrd)
-       # matches /usr/isolinux/pl_version
-           initrd_version=$(/bin/cat /pl_version)
-           cd_version=$(/bin/cat /usr/isolinux/pl_version)
-
-           if [ "$initrd_version" != "$cd_version" ]; then
-           # eh, wrong cd, keep trying
-               /bin/umount /usr 2>&1 /dev/null
-           else
-               verbose-message "pl_sysinit: found CD and mounted on /usr"
-               _mounted=1
-               break
-           fi
-       fi
+        if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then
+            partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions)
+            for partition in $partitions ; do
+                echo $(date "+%H:%M:%S") "pl_sysinit: checking $partition for iso image"
+                mkdir -p /tmp/$partition
+                if /bin/mount -o ro -t msdos,ext2 /dev/$partition /tmp/$partition 2>&1 > /dev/null ; then
+                # Look for the first ISO image
+                    for iso in /tmp/$partition/*.iso ; do
+                        if /sbin/losetup /dev/loop0 $iso ; then
+                            echo $(date "+%H:%M:%S") "pl_sysinit: using $(basename $iso) on $partition"
+                            device="loop0"
+                            break
+                        fi
+                    done
+                    if [ "$device" != "loop0" ] ; then
+                        /bin/umount /tmp/$partition 2>&1 > /dev/null
+                    fi
+                fi
+            done
+        fi
+        
+        verbose-message "pl_sysinit: checking $device for /usr contents"
+        /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null
+        if [ $? -eq 0 ]; then
+        # it mounted, but we should probably make sure its our boot cd
+        # this can be done by making sure the /pl_version file (on initrd)
+        # matches /usr/isolinux/pl_version
+            initrd_version=$(/bin/cat /pl_version)
+            cd_version=$(/bin/cat /usr/isolinux/pl_version)
+
+            if [ "$initrd_version" != "$cd_version" ]; then
+            # eh, wrong cd, keep trying
+                /bin/umount /usr 2>&1 /dev/null
+            else
+                verbose-message "pl_sysinit: found CD and mounted on /usr"
+                _mounted=1
+                break
+            fi
+        fi
     done
     return $_mounted
 }
@@ -139,11 +139,11 @@ function create-device-mapper-node() {
     MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
     
     if [ -n "$MAJOR" ] && [ -n "$MINOR" ]; then
-       /bin/mkdir -p --mode=755 $DIR
-       /bin/rm -f $CONTROL
-       /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
+        /bin/mkdir -p --mode=755 $DIR
+        /bin/rm -f $CONTROL
+        /bin/mknod --mode=600 $CONTROL c $MAJOR $MINOR
     else
-       verbose-message "pl_sysinit: unable to create device mapper control node, continuing"
+        verbose-message "pl_sysinit: unable to create device mapper control node, continuing"
     fi
 }
 
@@ -174,14 +174,14 @@ function sync-clock() {
     baseMin=`uname -r | cut -d "." -f2`
     vers=`uname -r | cut -d "." -f3 | cut -d "-" -f1`
     if [ $baseMaj -eq 2 ];then
-       if [ $baseMin -eq 6 ]; then
+        if [ $baseMin -eq 6 ]; then
             if [ $vers -ge 32 ];then
-               if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
+                if [ "$(readlink /dev/rtc)" != "/dev/rtc0" ]; then
                     rm -f /dev/rtc
                     ln -s /dev/rtc0 /dev/rtc
-               fi
+                fi
             fi
-       fi
+        fi
     fi
     # save ntp clock to hardware
     /sbin/hwclock --systohc --utc