#!/bin/sh /etc/rc.common
#
# Copyright (C) 2019 rosysong@rosinson.com
#

START=99
USE_PROCD=1
SHARE_PATH=/www/rosyfs-share

service_triggers() {
	procd_add_reload_trigger rosyfs
}

start_service() {
	config_load rosyfs
	config_get disabled default disabled '0'
	config_get target default target ''

	[ $disabled -eq 1 ] && return

	[ -n "$target" -a ! "$(readlink $SHARE_PATH)" = "$target" ] && {
		rm -f $SHARE_PATH
		ln -s $target $SHARE_PATH
	}
}

stop_service() {
	rm -f $SHARE_PATH
}
