| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Author: Steven Shiau <steven _at_ clonezilla org> |
| 3 | # License: GPL |
| 4 | # Description: This program will startup the iptables NAT for DRBL clients when DRBL server boots. |
| 5 | # Note: This program is different with drbl-nat-rules |
| 6 | # drbl-nat-rules: a program to generate "NAT rules" for DRBL clients. |
| 7 | # drbl-clients-nat: a startup "NAT service" for DRBL server when it boots. |
| 8 | |
| 9 | ### BEGIN INIT INFO |
| 10 | # Provides: drbl-clients-nat |
| 11 | # Required-Start: $local_fs $all |
| 12 | # Required-Stop: |
| 13 | # X-Start-Before: |
| 14 | # X-Stop-After: |
| 15 | # Default-Start: 2 |
| 16 | # Default-Stop: |
| 17 | ### END INIT INFO |
| 18 | |
| 19 | #set -e |
| 20 | |
| 21 | DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" |
| 22 | |
| 23 | . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions |
| 24 | |
| 25 | export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" |
| 26 | |
| 27 | # |
| 28 | do_start_drbl_nat_rulesscip-shell shell shell-project 0.0.0 do_start_drbl_nat_rules().() { |
| 29 | if [scip-shell system . . `[`. -f $SYSCONF_PATH/drbl-nat.up.rules ]; then |
| 30 | iptables-restore < $SYSCONF_PATH/drbl-nat.up.rules |
| 31 | else |
| 32 | echoscip-shell system . . echo. "$SYSCONF_PATH/drbl-nat.up.rules is not found, skip this." |
| 33 | fi |
| 34 | } |
| 35 | do_stop_drbl_nat_rulesscip-shell shell shell-project 0.0.0 do_stop_drbl_nat_rules().() { |
| 36 | $DRBL_SCRIPT_PATH/sbin/drbl-nat-rules stop |
| 37 | } |
| 38 | |
| 39 | case "$1" in |
| 40 | start) |
| 41 | echoscip-shell system . . echo. -n "Starting the NAT services for DRBL clients... " |
| 42 | do_start_drbl_nat_rulesscip-shell shell shell-project 0.0.0 do_start_drbl_nat_rules(). |
| 43 | echoscip-shell system . . echo. "done!" |
| 44 | ;; |
| 45 | stop) |
| 46 | echoscip-shell system . . echo. -n "Stopping the NAT services for DRBL clients... " |
| 47 | do_stop_drbl_nat_rulesscip-shell shell shell-project 0.0.0 do_stop_drbl_nat_rules(). |
| 48 | echoscip-shell system . . echo. "done!" |
| 49 | ;; |
| 50 | restart) |
| 51 | $0 stop |
| 52 | $0 start |
| 53 | ;; |
| 54 | status) |
| 55 | iptables -L -t nat -n |
| 56 | ;; |
| 57 | |
| 58 | *) |
| 59 | echoscip-shell system . . echo. "Usage: $0 {start|stop|status}" |
| 60 | exit 1 |
| 61 | esac |
| 62 | |
| 63 | exit 0 |