Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (5) </ 1 2 [3] 4 5 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: preserve ssh cert and user base across boots?, how do I ?< Next Oldest | Next Newest >
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: June 24 2008,18:49 QUOTE

You can edit the shutdown scripts (in /etc/rc0.d/ - esp see S90knoppix-halt)
or somehow change your boot options (/proc/cmdline - probably will need some remounting magic)
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: June 24 2008,19:47 QUOTE

You can write to /proc/cmdline? How? Never heard of that being possible..

--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
bjhbjh Offline





Group: Members
Posts: 21
Joined: Jan. 2008
Posted: June 25 2008,14:40 QUOTE

Quote
Or is your problem really about the "Remove cd and press enter to finish rebooting/shutting down" message


Yes, that is the issue I'd like to avoid.

Not a problem when the power fails and returns but it IS a problem if I issue a 'restart' / 'reboot' (can't remember which is correct but you get my drift) command from a remote SSH session.

I'll try your install to MemKey suggestion, since I don't have an HD present on this box.

Thanks,

Brian H.
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: June 25 2008,17:04 QUOTE

Quote (curaga @ June 24 2008,19:47)
You can write to /proc/cmdline? How? Never heard of that being possible..

Never did it before... searchstring "write to /proc" gave me this

Guess it's more complicated than I thought.
Back to top
Profile PM 
chaostic Offline





Group: Members
Posts: 328
Joined: Mar. 2005
Posted: June 26 2008,01:17 QUOTE

Quote (bjhbjh @ June 25 2008,10:40)
Quote
Or is your problem really about the "Remove cd and press enter to finish rebooting/shutting down" message


Yes, that is the issue I'd like to avoid.

Not a problem when the power fails and returns but it IS a problem if I issue a 'restart' / 'reboot' (can't remember which is correct but you get my drift) command from a remote SSH session.

I'll try your install to MemKey suggestion, since I don't have an HD present on this box.

Thanks,

Brian H.

I made a quick script you can use to prevent the ejecting. You just need a way of running it before you issue a reboot.


Code Sample

#!/bin/bash
#
# Quickly change knoppix-reboot to prevent cd eject
#

# Remove sym-link to /KNOPPIX/ copy from /ramdisk/ copy
sudo rm -r /etc/init.d/knoppix-reboot &&

# Copy original RC script to /ramdisk/ copy
# sudo cp /KNOPPIX/etc/init.d/knoppix-reboot /etc/init.d/knoppix-reboot &&
sudo cat  > /tmp/knoppix-reboot << COSMIC &&
#!/bin/sh

PATH=/sbin:/bin:/usr/bin:/usr/sbin
export PATH

exec >/dev/console 2>&1 </dev/console

NORMAL="^[[0;39m"
RED="^[[1;31m"
GREEN="^[[1;32m"
YELLOW="^[[1;33m"
BLUE="^[[1;34m"
MAGENTA="^[[1;35m"
CYAN="^[[1;36m"
WHITE="^[[1;37m"
                                       
stringinstring(){
 case "$2" in *$1*) return 0;; esac
 return 1
}

INSTALLED=""
TORAM=""
FRUGAL=""
[ -e /KNOPPIX/bin/ash ] || INSTALLED=yes

if [ -e /etc/sysconfig/toram ]; then
 INSTALLED=yes
 TORAM=yes
fi
if [ -e /etc/sysconfig/frugal ]; then
 INSTALLED=yes
 FRUGAL=yes
fi

case "$0" in
 *halt)
       message="
${YELLOW}DSL halted.${NORMAL}"
       command="halt"
       options="-p -d -i -f"
       ;;
 *reboot)
       message="${GREEN}Preparing for reboot...${NORMAL}"
       command="reboot"
       options="-r -d -i -f"
       ;;
 *)
       echo "$0: call this script as \"halt\" or \"reboot\" please!"
       exit 1
       ;;
esac

[ -n "$INSTALLED" ] || options="$options -n"

mysleep() {
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
do
usleep 75000
echo -n "$1.${NORMAL}"
done
echo ""
}

if [ -x /opt/powerdown.sh ]; then
 /opt/powerdown.sh
fi

echo "0" > /proc/sys/kernel/printk

if pidof cardmgr >/dev/null 2>&1; then
echo -n "${BLUE}Shutting down PCMCIA devices...${NORMAL}"
cardctl eject >/dev/null 2>&1
sleep 2
echo ""
fi

killall5 -15
sleep 1
echo -n "${BLUE}Sent all processes the TERM signal...${NORMAL}"
mysleep "$BLUE"

killall5 -9
sleep 1
echo -n "${RED}Sent all processes the KILL signal...${NORMAL}"
mysleep "$RED"

NETMOUNTS="$(awk '{if($1~/:/){print $2}}' /proc/mounts 2>/dev/null)"
if [ -n "$NETMOUNTS" ]; then
echo "${BLUE}Unmounting network filesystems.${NORMAL}"
umount -t nfs -arvf 2>/dev/null
fi

NETDEVICES="$(awk -F: '/eth.:/{print $1}' /proc/net/dev 2>/dev/null)"
if [ -n "$NETDEVICES" ]; then
pidof pump >/dev/null 2>&1 && { pump -k; sleep 2; }
echo -n "${BLUE}Shutting down network device${NORMAL}"
for n in $NETDEVICES; do
echo -n " ${MAGENTA}$n${NORMAL}
ifconfig $n down
done
echo ""
fi

NOPROMPT=""
read CMDLINE <<EOT
$(cat /proc/cmdline 2>/dev/null)
EOT
case "$CMDLINE" in *noprompt*) NOPROMPT="yes";;; esac
FINALCMD="/sbin/$command"
if [ -z "$INSTALLED" -a -z "$NOPROMPT" ]; then
[ -x /etc/init ] || cp -p /sbin/init /etc/
[ -x /etc/init ] && FINALCMD="/etc/init"
fi

if [ -n "$FRUGAL" ]; then
  stringinstring "KNOPPIX" "$FINALCMD" || FINALCMD="/KNOPPIX$FINALCMD"
fi
if [ -n "$TORAM" ]; then
  stringinstring "KNOPPIX" "$FINALCMD" || FINALCMD="/KNOPPIX$FINALCMD"
fi

swapoff -a >/dev/null 2>&1

echo "${BLUE}Unmounting file systems.${NORMAL}"
NOEJECT=""
read CMDLINE <<EOT
$(cat /proc/cmdline 2>/dev/null)
EOT
case "$CMDLINE" in *noeject*) NOEJECT="yes";;; esac
for dev in /proc/sys/dev/cdrom*/lock; do [ -f "$dev" ] && echo 0 > "$dev"; done

cd /

umount -arvf 2>/dev/null
if [ "$?" != "0" ]; then
for i in /dev/loop*; do losetup -d $i 2>/dev/null; done
umount -arf 2>/dev/null
fi

rmmod -a >/dev/null 2>&1

[ -n "$INSTALLED" ] && mount -o remount,ro / 2>/dev/null

echo "$message" >/dev/console

exec $FINALCMD $options 2>/dev/null
COSMIC

# Move temp file to final spot
sudo mv /tmp/knoppix-reboot /etc/init.d/knoppix-reboot &&

# Recreate symlink from RC6.d to /ramdisk/ copy instead of to /KNOPPIX/ copy
sudo ln -sf /etc/init.d/knoppix-reboot /etc/rc6.d/S90knoppix-reboot &&

echo "Should be done. Enjoy :)" || echo "Something failed :("


Copy that entire thing into a file, and then "chmod 755 [filename]".

Everything uses sudo. If it fails, it should tell you. All it does, is removes the original symlink, creates a new temp copy (I tried to use a diff/patch, but it kept failing for no reason, only inside of the script), moves it over, then replaces a second symlink. Let me know if it works.

The gist of it is that I removed the actions of ejecting the cd and waiting for enter to be pressed.

It would still be better to try a usb flash drive, imho.

Edit: This copy of the reboot script is from 3.4.11, so I don't know if 4.x has any differences.
Back to top
Profile PM 
20 replies since June 23 2008,01:38 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (5) </ 1 2 [3] 4 5 >/
reply to topic new topic new poll
Quick Reply: preserve ssh cert and user base across boots?

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code