How to auto-reboot a SUN, then auto-login, then auto-start a program?

How to auto-reboot a SUN, then auto-login, then auto-start a program?

Post by Song H » Thu, 18 Jan 2001 05:17:37



My Sun (Solaris 2.6) server is running a program as a listener, when it
receives the "installation" command from remote user, it will call a
script which will automatically reboot the machine, then auto-login,
then automatically restart the listener to do the installation ...

Does anyone know how to implement this script,

Thanks a lot,

Song

 
 
 

How to auto-reboot a SUN, then auto-login, then auto-start a program?

Post by Song H » Thu, 18 Jan 2001 05:26:52


My Sun (Solaris 2.6) server is running a program as a listener, when it
receives the "installation" command from remote user, it will call a
script which will automatically reboot the machine, then auto-login,
then automatically restart the listener to do the installation ...

Does anyone know how to implement this script,

Thanks a lot,



 
 
 

How to auto-reboot a SUN, then auto-login, then auto-start a program?

Post by Carlos Plarr » Thu, 18 Jan 2001 11:29:41




> My Sun (Solaris 2.6) server is running a program as a listener, when
it
> receives the "installation" command from remote user, it will call a
> script which will automatically reboot the machine, then auto-login,
> then automatically restart the listener to do the installation ...

> Does anyone know how to implement this script,

> Thanks a lot,



Hi

I have a script that does not do exactly what you want, but it
runs a set of scripts that are stored in a certain directory
and runs them in the order they are listed.

The program creates a dummy script that runs before the first
reboot, then it reboots and uses at to reactivate at the
next reboot running the first script. Then it reboots, and
runs the next, and reboots and so on. It may give you an
idea of how it works.

I've tested it on Solaris and Linux (changing the configuration) and
it seems to work OK. Hope it helps.

#!/bin/bash

# We need write permissions over the $SCRIPT_DIR and scripts.
# Scriptnames with trailing ".$SUFFIX" suffix are not supported.
export SCRIPT_DIR="/root/hola/scripts"

# Shell to use to run the scripts.
export SHELL_TO_RUN=/bin/bash

# Shell arguments.
export SHELL_TO_RUN_ARGS=
# export SHELL_TO_RUN_ARGS=-x

# Time to wait in seconds between scripts and shutdowns.
export SCRIPT_DELAY=5
# Time in Seconds.

# Time in minutes that it takes to do a shutdown.
export SHUTDOWN_TIME=2
# Time in minutes.

# Shutdown command
export SHUTDOWN_CMD="sync ; sync ; sync ; /sbin/reboot"

# chmod command.
export CHMOD=/bin/chmod

# mode for shell scripts.
export MODE=700

# rm command.
export RM_CMD=/bin/rm

# tr command.
export TR=/usr/bin/tr

# cut command.
export CUT=/usr/bin/cut

# sleep command.
export SLEEP=/bin/sleep

# at command.
export AT_CMD=/usr/bin/at

# at arguments.
export AT_ARGS="now + $SHUTDOWN_TIME minutes"

# at list.
export AT_LIST="-l"

# Suffix for the new shell scripts. Please include the dot.
export SUFFIX=".cont"

# Name of dummy program to initiate runs.
export DUMMY="Dummy.program"

# * * * * * * From here on there are no user configurable parts. * * * *
* *
cd /
echo "Removing old $0 auxiliary scripts."
$RM_CMD $SCRIPT_DIR/*$SUFFIX $SCRIPT_DIR/$DUMMY 2>/dev/null # Delete the
new shell scripts.
echo "Configuring shell scripts."
export BEFORE="$SCRIPT_DIR/$DUMMY" # Have a dummy program to start.
for name in $SCRIPT_DIR/*
do
        echo "$SHELL_TO_RUN $SHELL_TO_RUN_ARGS $BEFORE" >
"$BEFORE$SUFFIX"
        echo "$SLEEP $SCRIPT_DELAY" >> "$BEFORE$SUFFIX"
        echo "echo $name$SUFFIX | $AT_CMD $AT_ARGS" >> "$BEFORE$SUFFIX"
        echo "$SLEEP $SCRIPT_DELAY" >> "$BEFORE$SUFFIX"
        echo "echo Pending at commands:" >> "$BEFORE$SUFFIX"
        echo "$AT_CMD $AT_LIST" >> "$BEFORE$SUFFIX"
        echo "$SLEEP" "$SCRIPT_DELAY" >> "$BEFORE$SUFFIX"
        echo "$SHUTDOWN_CMD" >>  "$BEFORE$SUFFIX"
        echo "$SHELL_TO_RUN $SHELL_TO_RUN_ARGS $name" > "$name$SUFFIX"
        echo "$SLEEP $SCRIPT_DELAY" >> "$name$SUFFIX"
        echo "$RM_CMD $SCRIPT_DIR/*$SUFFIX" >> "$name$SUFFIX"
        echo "$SLEEP $SCRIPT_DELAY" >> "$name$SUFFIX"
        echo "$SHUTDOWN_CMD" >>  "$name$SUFFIX"
        "$CHMOD" "$MODE" "$BEFORE" "$BEFORE$SUFFIX" "$name"
"$name$SUFFIX" 2>/dev/null
        export BEFORE="$name"
        echo "$BEFORE has been configured."
done
echo "echo" > "$SCRIPT_DIR/$DUMMY" # Only do a dummy instruction in
dummy program.

# Finally beginning execution of the whole thing ;)
echo "Beginning batch routines."
$SHELL_TO_RUN $SHELL_TO_RUN_ARGS $SCRIPT_DIR/$DUMMY$SUFFIX

--
Carlos Plarre
Brainbench MVP for UNIX Admin

Sent via Deja.com
http://www.deja.com/

 
 
 

1. How can I auto-reboot a SUN, then auto-login, then auto-start a program?

My Sun (Solaris 2.6) server is running a program as a listener, when it
receives the "installation" command from remote user, it will call a
script which will automatically reboot the machine, then auto-login,
then automatically restart the listener to do the installation ...

Does anyone know how to implement this script,

Thanks a lot,

Hua.


2. FreeBSD 2.2.2 CD-ROM

3. nis, nfs, autofs: auto.master, auto.misc, auto.home help please

4. 1600x1200 mode possible in XFree86?

5. auto login / auto program startup

6. SUMMARY: Can't delete mail messages.

7. AUTO START OPENWIN UPON REBOOT, not LOGIN

8. Query the compiler version of an executable

9. How to get Apache to Auto-Start at Reboot?

10. auto-login when reboot?

11. Auto Start Programs After Reboot

12. listener auto-start question for SUN Solaris

13. auto-crossover - auto-MDI/X capability of ethernet NIC