forked from Spark/ssm-services
32 lines
837 B
Plaintext
Executable File
32 lines
837 B
Plaintext
Executable File
#!/usr/bin/env watchman
|
|
|
|
service_type='oneshot'
|
|
|
|
cfg_mounts+=( 'dev:devtmpfs:defaults:/dev' )
|
|
cfg_mounts+=( '/dev/pts:devpts:noexec,nosuid,gid=5,mode=0620:/dev/pts' )
|
|
cfg_mounts+=( '/dev/mqueue:mqueue:noexec,nosuid,nodev:/dev/mqueue' )
|
|
cfg_mounts+=( 'tmpfs:tmpfs:defaults,mode=0777:/dev/shm' )
|
|
|
|
spawn() {
|
|
for m in ${cfg_mounts[@]}; do
|
|
fs_dev=`echo "$m" | cut -d':' -f1`
|
|
fs_type=`echo "$m" | cut -d':' -f2`
|
|
fs_opts=`echo "$m" | cut -d':' -f3`
|
|
fs_mountpoint=`echo "$m" | cut -d':' -f4`
|
|
|
|
mountpoint -q "$fs_mountpoint" || {
|
|
[[ -d "$fs_mountpoint" ]] || { mkdir "$fs_mountpoint"; }
|
|
mount "$fs_dev" -n -t "$fs_type" -o "$fs_opts" "$fs_mountpoint"
|
|
}
|
|
done
|
|
}
|
|
|
|
stop() {
|
|
for m in "${cfg_mounts[@]}"; do
|
|
fs_mountpoint=`echo "$m" | cut -d ':' -f 4`
|
|
mountpoint -q "$fs_mountpoint" && {
|
|
umount "$fs_mountpoint"
|
|
}
|
|
done
|
|
}
|