From: <abe...@us...> - 2015-12-05 02:54:16
|
Revision: 7372 http://sourceforge.net/p/astlinux/code/7372 Author: abelbeck Date: 2015-12-05 02:54:14 +0000 (Sat, 05 Dec 2015) Log Message: ----------- kernel-reboot, set a working dir for when called via PHP, otherwise shell-init errors are displayed on video consoles, only cosmetic Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot Modified: branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot =================================================================== --- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-05 01:17:16 UTC (rev 7371) +++ branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-05 02:54:14 UTC (rev 7372) @@ -162,6 +162,9 @@ do_failure } +# Set a working dir for when called via PHP +cd /root + if [ ! -x /sbin/kexec ]; then echo "You don't have kexec-tools installed - rebooting" reboot This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2015-12-05 14:21:23
|
Revision: 7373 http://sourceforge.net/p/astlinux/code/7373 Author: abelbeck Date: 2015-12-05 14:21:21 +0000 (Sat, 05 Dec 2015) Log Message: ----------- kernel-reboot, add a 'sync' and allow only root users Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot Modified: branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot =================================================================== --- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-05 02:54:14 UTC (rev 7372) +++ branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-05 14:21:21 UTC (rev 7373) @@ -166,13 +166,13 @@ cd /root if [ ! -x /sbin/kexec ]; then - echo "You don't have kexec-tools installed - rebooting" + echo "kernel-reboot: You don't have kexec-tools installed - rebooting" >&2 reboot exit 1 fi if [ ! -x /sbin/findfs ]; then - echo "You don't have findfs installed - rebooting" + echo "kernel-reboot: You don't have findfs installed - rebooting" >&2 reboot exit 1 fi @@ -187,10 +187,17 @@ esac fi +if [ $(id -u) -ne 0 ]; then + echo "kernel-reboot: Operation not permitted, must be root" >&2 + exit 1 +fi + if [ -n "$DELAY" ] && [ $DELAY -gt 0 ]; then sleep $DELAY fi +sync + # Ignore terminating signals from here on trap '' HUP INT TERM This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2015-12-06 16:18:52
|
Revision: 7374 http://sourceforge.net/p/astlinux/code/7374 Author: abelbeck Date: 2015-12-06 16:18:49 +0000 (Sun, 06 Dec 2015) Log Message: ----------- kernel-reboot, add some output text per Michael's suggestions Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot Modified: branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot =================================================================== --- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-05 14:21:21 UTC (rev 7373) +++ branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-06 16:18:49 UTC (rev 7374) @@ -22,7 +22,8 @@ do_failure() { - reboot -f + echo '## Falling back to /sbin/reboot ##' + /sbin/reboot -f exit 1 } @@ -31,6 +32,8 @@ # Stop services and unmount all file systems or remount 'ro' if busy /etc/rc shutdown + echo '## Using /sbin/kernel-reboot ##' + # Stop udevd since /dev is now 'ro' echo "Stopping udevd..." udevadm control --timeout=121 --exit @@ -58,7 +61,7 @@ mount -t vfat -o ro "$LABEL" $BASE fi if ! mount | grep -q "$BASE"; then - echo "Unable to find Runnix partition." + echo "Unable to find RUNNIX partition." do_failure fi fi @@ -166,14 +169,14 @@ cd /root if [ ! -x /sbin/kexec ]; then - echo "kernel-reboot: You don't have kexec-tools installed - rebooting" >&2 - reboot + echo "kernel-reboot: You don't have kexec-tools installed, falling back to /sbin/reboot" >&2 + /sbin/reboot exit 1 fi if [ ! -x /sbin/findfs ]; then - echo "kernel-reboot: You don't have findfs installed - rebooting" >&2 - reboot + echo "kernel-reboot: You don't have findfs installed, falling back to /sbin/reboot" >&2 + /sbin/reboot exit 1 fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2015-12-09 00:04:29
|
Revision: 7386 http://sourceforge.net/p/astlinux/code/7386 Author: abelbeck Date: 2015-12-09 00:04:27 +0000 (Wed, 09 Dec 2015) Log Message: ----------- kernel-reboot, fix un-setup image issues by moving '/etc/rc shutdown' to then end and simplifying. Now works with un-setup images (no unionfs) and with and without 'noram' in the KCMD. Hopefully we have a production version. Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot Modified: branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot =================================================================== --- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-08 15:07:11 UTC (rev 7385) +++ branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-09 00:04:27 UTC (rev 7386) @@ -23,36 +23,16 @@ do_failure() { echo '## Falling back to /sbin/reboot ##' - /sbin/reboot -f + sleep 1 + /sbin/reboot exit 1 } do_reboot() { - # Stop services and unmount all file systems or remount 'ro' if busy - /etc/rc shutdown - + echo '' echo '## Using /sbin/kernel-reboot ##' - # Stop udevd since /dev is now 'ro' - echo "Stopping udevd..." - udevadm control --timeout=121 --exit - killall udevd 2>/dev/null - - ROOT="/tmp/mnt/root" - - KEXEC_BASE="/tmp/mnt/kexec" - - # We may have lost /proc on the shutdown, mount if missing - if [ ! -e /proc/mounts ]; then - mount -t proc none /proc - fi - - mount -t tmpfs none /tmp - - mkdir -p "$ROOT" - mkdir -p "$KEXEC_BASE" - BASE="/oldroot/cdrom" if ! mount | grep -q "$BASE"; then @@ -66,6 +46,10 @@ fi fi + ROOT="/tmp/mnt/root" + + mkdir -p "$ROOT" + if [ -f $BASE/os/default.conf ]; then . $BASE/os/default.conf fi @@ -100,19 +84,20 @@ INITRD="${BASE}${INITRD#/mnt/base}" KERN="${ROOT}${KERN#/mnt/root}" + # Find first unused loop device + DEVLOOP="$(losetup -f)" + if [ -z "$OFFSET" ]; then - losetup /dev/loop0 $BASE/os/$RUNIMG + losetup $DEVLOOP $BASE/os/$RUNIMG else - losetup -o "$OFFSET" /dev/loop0 $BASE/os/$RUNIMG + losetup -o "$OFFSET" $DEVLOOP $BASE/os/$RUNIMG fi if [ -z "$FSTYPE" ]; then FSTYPE="ext2" fi - if mount -t $FSTYPE -o ro /dev/loop0 $ROOT; then - echo "Root mounted" - else + if ! mount -t $FSTYPE -o ro $DEVLOOP $ROOT; then echo "Error mounting $RUNIMG root fs" do_failure fi @@ -141,28 +126,33 @@ KERN="$ROOT/boot/bzImage" fi - if [ -f "$INITRD" -a -f "$KERN" ]; then - echo "Copying kernel and initrd to ramdisk..." - mount -t tmpfs none "$KEXEC_BASE" - cp "$INITRD" "$KEXEC_BASE/initrd.img" - cp "$KERN" "$KEXEC_BASE/bzImage" - echo "Unmounting image..." + if [ -n "$KCMD" -a -f "$INITRD" -a -f "$KERN" ]; then + echo "Loading new kernel..." + if ! /sbin/kexec -l --command-line="$KCMD" --initrd="$INITRD" "$KERN"; then + umount $ROOT + do_failure + fi umount $ROOT else - echo "I couldn't find your kernel and/or initrd" + echo "Missing one or more of: kcmd, initrd, kernel" + umount $ROOT do_failure fi - if [ -z "$KCMD" ]; then - echo "You need to specify a kernel command line. - I can't guess that" - do_failure - fi + # Stop services and unmount all file systems or remount 'ro' if busy + /etc/rc shutdown + echo "Stopping udevd..." + udevadm control --timeout=121 --exit + killall udevd 2>/dev/null + echo "Trying kexec..." - /sbin/kexec --command-line="$KCMD" --initrd="$KEXEC_BASE/initrd.img" -f "$KEXEC_BASE/bzImage" + /sbin/kexec -e - do_failure + echo '## Falling back to /sbin/reboot ##' + sleep 1 + /sbin/reboot -f + exit 1 } # Set a working dir for when called via PHP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2015-12-09 04:36:06
|
Revision: 7388 http://sourceforge.net/p/astlinux/code/7388 Author: abelbeck Date: 2015-12-09 04:36:04 +0000 (Wed, 09 Dec 2015) Log Message: ----------- kernel-reboot, tweak to allow the vfat partition to be un-mounted before the kexec Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot Modified: branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot =================================================================== --- branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-09 00:08:58 UTC (rev 7387) +++ branches/1.0/project/astlinux/target_skeleton/sbin/kernel-reboot 2015-12-09 04:36:04 UTC (rev 7388) @@ -139,6 +139,9 @@ do_failure fi + cd /root + losetup -d $DEVLOOP + # Stop services and unmount all file systems or remount 'ro' if busy /etc/rc shutdown This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |