On 12/14/2011 08:24 AM, Peter Naulls wrote:

sysupgrade fails in non-interactive shells to lack of sourcing /etc/profile
and therefore setting PATH completely, so can't find tools at the end.

In addition, there's an issue with sysupgrade, when performed over
an ssh connection, leaving the connection hanging, since it reboots
without a clean shutdown.

I know it's possible to do keepalives and whatnot, but I'd prefer a
definitive close.  My goal here is to do a fully automated sys upgrade
driven via ssh.

The attached is what I came up with.  It does require setsid, which
I don't think is part of the standard setup (I'm using it anyway
for unrelated reasons).  This patch also contains a long-pending
minor patch so that sysupgrade works for e/glibc.

There may be a better way to do all this.

Signed-off-by: Peter Naulls <pe...@chocky.org>

Index: files/lib/upgrade/common.sh
===================================================================
--- files/lib/upgrade/common.sh	(revision 29529)
+++ files/lib/upgrade/common.sh	(working copy)
@@ -52,13 +52,14 @@
 		/sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd   \
 		/bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
 		/bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump          \
-		/bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
+		/bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc \
+		/usr/bin/killall /usr/bin/setsid
 
 	install_bin /sbin/mtd
 	for file in $RAMFS_COPY_BIN; do
 		install_bin $file
 	done
-	install_file /etc/resolv.conf /etc/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
+	install_file /etc/resolv.conf /etc/functions.sh /lib/* /lib/upgrade/*.sh $RAMFS_COPY_DATA
 
 	pivot $RAM_ROOT /mnt || {
 		echo "Failed to switch over to ramfs. Please reboot."
@@ -219,7 +220,8 @@
 	[ -n "$DELAY" ] && sleep "$DELAY"
 	ask_bool 1 "Reboot" && {
 		v "Rebooting system..."
-		reboot -f
+                setsid sh -c "sleep 1; reboot -f"  >/dev/null </dev/null 2>/dev/null &
+                killall dropbear || true
 		sleep 5
 		echo b 2>/dev/null >/proc/sysrq-trigger
 	}
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to