| 1 | #!/sbin/openrc-run |
| 2 | command="/usr/bin/noip2" |
| 3 | command_user="noip:noip" |
| 4 | procname="noip2" |
| 5 | |
| 6 | description="no-ip.com Dynamic DNS Update Client" |
| 7 | description_checkconfig="Verify existenace of a configuration file" |
| 8 | description_configure="Generate a configuration file" |
| 9 | |
| 10 | extra_commands="checkconfig configure" |
| 11 | |
| 12 | depend() { |
| 13 | use logger dns |
| 14 | need net |
| 15 | } |
| 16 | |
| 17 | checkconfig() { |
| 18 | if [ ! -f "${CFGFILE}" ] ; then |
| 19 | eerror "Please create ${CFGFILE} by using the command configure" |
| 20 | return 1 |
| 21 | fi |
| 22 | return 0 |
| 23 | } |
| 24 | |
| 25 | configure() { |
| 26 | if [ -r "${CFGFILE}" ] ; then |
| 27 | read -p "Configuration file already exist, overwrite it? [y/N]: " a |
| 28 | if [[ "$a" != "y" ]] && [[ "$a" != "Y" ]] ; then |
| 29 | eerror "Aborting" |
| 30 | return 1 |
| 31 | fi |
| 32 | fi |
| 33 | |
| 34 | su -mp -s /bin/sh noip -c "$command -C" |
| 35 | } |
| 36 | |
| 37 | start_pre() { |
| 38 | if [ "${RC_CMD}" != "restart" ] ; then |
| 39 | checkconfig || return $? |
| 40 | fi |
| 41 | } |
| 42 | |
| 43 | stop_pre() { |
| 44 | if [ "${RC_CMD}" = "restart" ] ; then |
| 45 | checkconfig || return $? |
| 46 | fi |
| 47 | } |
| 48 | |