File tree Expand file tree Collapse file tree 1 file changed +6
-35
lines changed Expand file tree Collapse file tree 1 file changed +6
-35
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
- # ## BEGIN INIT INFO
3
- # Provides:
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Saves or loads VBox's shared folders
9
- # Description: Saves or loads VBox's shared folders
10
- # ## END INIT INFO
11
-
12
2
set -e
13
3
set -x
14
4
15
5
# https://raw.githubusercontent.com/fhd/init-script-template/master/template
16
6
17
- dir=" "
18
- cmd=" "
19
- user=" "
20
-
21
- name=` basename $0 `
22
-
23
7
DUMP_FILE=/var/local/shared-saver-dump
24
- KERNEL_PASSPHRASE=root
25
- # KERNEL_PASSPHRASE=khack-kexec
26
-
27
- LOGFILE=" /home/vagrant/shared-saver-log-$( date ' +%Y-%m-%d-%H-%M-%S' ) "
28
- log () {
29
- echo " $@ " >> " $LOGFILE "
30
- }
31
8
32
9
save_file () {
33
- log ' saving mounts '
34
- mount | perl -ne ' print "$1\t$2\tvboxsf\tdefaults\t0\t0$/" if /^([\w\/] +) on (.+) type vboxsf \(.+\)$/' | tee " $DUMP_FILE "
10
+ echo ' saving'
11
+ mount | perl -ne ' print "$1\t$2\tvboxsf\tdefaults\t0\t0$/" if /^(\S +) on (.+) type vboxsf \(.+\)$/' | tee " $DUMP_FILE "
35
12
}
36
13
37
14
is_magic () {
@@ -40,35 +17,29 @@ is_magic() {
40
17
41
18
force_load_file () {
42
19
if [ -f " $DUMP_FILE " ]; then
20
+ ' file found, loading'
43
21
mount -aT " $DUMP_FILE "
44
22
else
45
- log ' file not found, skipping'
23
+ echo ' file not found, skipping'
46
24
fi
47
25
}
48
26
49
27
load_file () {
50
- log ' loading mounts, before checking'
28
+ echo ' loading mounts, before checking'
51
29
if is_magic; then
52
30
force_load_file
53
31
fi
54
32
}
55
33
56
34
case " $1 " in
57
35
start)
58
- # TODO do we need to handle /var/lock/subsys? https://unix.stackexchange.com/a/114277
59
- # TODO read state if we have the magic passphrase in kernel CLI
60
36
load_file
61
37
;;
62
38
stop)
63
- # TODO dump state to file
64
39
save_file
65
40
;;
66
- status)
67
- # We're never running
68
- echo " This is useless"
69
- ;;
70
41
* )
71
- echo " Usage: $0 {start|stop|status }"
42
+ echo " Usage: $0 {start|stop}"
72
43
exit 1
73
44
;;
74
45
esac
You can’t perform that action at this time.
0 commit comments