aboutsummaryrefslogtreecommitdiff
path: root/target/device/valka/target_skeleton/etc/rc.d/nbd_swap
diff options
context:
space:
mode:
Diffstat (limited to 'target/device/valka/target_skeleton/etc/rc.d/nbd_swap')
-rwxr-xr-xtarget/device/valka/target_skeleton/etc/rc.d/nbd_swap31
1 files changed, 31 insertions, 0 deletions
diff --git a/target/device/valka/target_skeleton/etc/rc.d/nbd_swap b/target/device/valka/target_skeleton/etc/rc.d/nbd_swap
new file mode 100755
index 0000000000..b2a4a9c25c
--- /dev/null
+++ b/target/device/valka/target_skeleton/etc/rc.d/nbd_swap
@@ -0,0 +1,31 @@
+#!/bin/ash
+. /etc/rc.subr
+
+start() {
+ echo -n " * Starting nbd swap: "
+ if [ ! -x ${nbd_swap_program} ]; then
+ log_error "Missing 'nbd_client' program (${nbd_swap_program})"
+ echo "Failed"
+ return 1
+ fi
+
+ mknod ${nbd_swap_device} b 43 0
+ ${nbd_swap_program} ${nbd_swap_server} ${nbd_swap_port} ${nbd_swap_device} &
+ pid=$!
+ if [ "$?" -eq 0 ]; then
+ echo "${pid}" > ${nbd_swap_pidfile}
+ mkswap ${nbd_swap_device}
+ swapon ${nbd_swap_device}
+ echo "Ok"
+ else
+ echo "Failed"
+ fi
+}
+
+stop() {
+ echo " * Stopping nbd swap..."
+ swapoff ${nbd_swap_device}
+ killpid ${nbd_swap_pidfile}
+}
+
+rc_run_command "$1" "nbd_swap"