-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
executable file
·93 lines (88 loc) · 2.07 KB
/
run.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
setenv="/usr/local/bin/envdir /home/$USER/env"
PATH="/home/test/bin:$PATH"
no_command() {
echo "command is not configured for $USER"
exit 1
}
command="$SSH_ORIGINAL_COMMAND"
set -- $command
action="$1"
case "$action" in
""|"console")
exec /usr/local/bin/console "$USER"
;;
"bsdcons")
if ! test -f /var/consoles/$USER; then no_command; fi
exec bsdcons.sh /var/consoles/$USER
;;
"on"|"off"|"cycle"|"reset")
if ! test -f /home/$USER/env/powerdevice; then no_command; fi
if $setenv checklock.sh; then
exec $setenv power.sh $action
fi
;;
"powerdown"|"powerup"|"reboot")
if $setenv checklock.sh; then
exec $setenv $action.sh
fi
;;
"install"|"upgrade"|"dhcp"|"linux")
if ! test -f /home/$USER/env/install; then no_command; fi
if $setenv checklock.sh; then
shift
exec $setenv setup.sh $action $*
fi
;;
"env")
if $setenv checklock.sh; then
exec $setenv env
fi
;;
"lock")
exec $setenv lock.sh
;;
"unlock")
exec $setenv unlock.sh
;;
"scp")
case "$command" in
"scp -t .")
exec scp -t /var/spool/tftp/$USER
;;
"scp -r -t .")
exec scp -r -t /var/spool/tftp/$USER
;;
esac
;;
"info")
exec $setenv info.sh
;;
"help")
echo " - console"
echo "powerup - power up machine if not already running"
echo "powerdown - shutdown machine gracefully, turn power off"
echo "reboot - reboot machine gracefully"
if test -f /home/$USER/env/powerdevice; then
echo "on - power on"
echo "off - power off"
echo "cycle - power cycle"
echo "reset - power reset"
fi
if test -f /home/$USER/env/install; then
echo "install - install current snapshot"
echo "upgrade - upgrade to current snapshot"
echo "dhcp - boot with dhcp from tftp once"
fi
echo "bsdcons - console message of previous OpenBSD boot"
echo "env - show environment"
echo "lock - lock access to machine"
echo "unlock - remove lock from machine"
echo "info - collect information on machine"
echo "scp - copy boot files to tftp server, use scp -O"
echo "help - print this message"
;;
*)
echo "unknown command";;
esac
exit 1