-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-for-short-time.sh
executable file
·56 lines (43 loc) · 1.4 KB
/
test-for-short-time.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
#!/bin/sh
# We do *not* abort this script in case of errors because that would abort the recovery.
#set -e
if [ -z "$1" ] ; then
echo "Usage: $0 result-symlink" >&2
exit 1
elif [ ! -x "$1/bin/switch-to-configuration" ] ; then
echo "Error: file missing: $1/bin/switch-to-configuration" >&2
exit 1
fi
cp --remove-destination -dT /run/current-system result.old || exit $?
logger "test-for-short-time.sh: switching to configuration $1 (`realpath "$1"`)..."
timeout 300 "$1/bin/switch-to-configuration" test
echo ""
echo "========================"
echo ""
echo "Configuration has been applied. We will roll back to the old configuration soon. Press ctrl+c to keep the current configuration."
echo ""
echo "If you want to keep the configuration, don't forget to do: $1/bin/switch-to-configuration boot"
for x in `seq 180 -10 10` ; do
echo -n "$x.. "
sleep 10
done
echo ""
echo "Rolling back to $(realpath result.old)..."
logger "test-for-short-time.sh: rollback to configuration $PWD/result.old (`realpath result.old`)..."
timeout 300 "./result.old/bin/switch-to-configuration" test
echo "I will reboot in 180 seconds unless you press ctrl+c"
for x in `seq 180 -10 10` ; do
echo -n "$x.. "
sleep 10
done
echo ""
echo "Rebooting..."
logger "test-for-short-time.sh: rebooting..."
reboot
sleep 180
echo "Will do hard reboot soon..."
sleep 10
logger "test-for-short-time.sh: hard reboot..."
sleep 1
sync
reboot -f