| 59 | | ${IPTABLES} -I INPUT -p tcp --dport 25 |
|---|
| 60 | | ${IPTABLES} -I OUTPUT -p tcp --sport 25 |
|---|
| | 101 | ${IPTABLES} -I ISPCP_INPUT -p tcp --dport 143 2>> "$LOGFILE" |
|---|
| | 102 | ${IPTABLES} -I ISPCP_OUTPUT -p tcp --sport 143 2>> "$LOGFILE" |
|---|
| | 103 | |
|---|
| | 104 | # mail traffic |
|---|
| | 105 | |
|---|
| | 106 | ${IPTABLES} -I ISPCP_INPUT -p tcp --dport 25 2>> "$LOGFILE" |
|---|
| | 107 | ${IPTABLES} -I ISPCP_OUTPUT -p tcp --sport 25 2>> "$LOGFILE" |
|---|
| | 108 | |
|---|
| | 109 | # Explicit return once done |
|---|
| | 110 | ${IPTABLES} -A ISPCP_INPUT -j RETURN |
|---|
| | 111 | ${IPTABLES} -A ISPCP_OUTPUT -j RETURN |
|---|
| | 112 | |
|---|
| | 113 | # Touch lock file |
|---|
| | 114 | touch $LFILE |
|---|
| | 115 | } |
|---|
| | 116 | |
|---|
| | 117 | remove_rules() { |
|---|
| | 118 | ${IPTABLES} -D INPUT -j ISPCP_INPUT 2>> "$LOGFILE" |
|---|
| | 119 | ${IPTABLES} -D OUTPUT -j ISPCP_OUTPUT 2>> "$LOGFILE" |
|---|
| | 120 | ${IPTABLES} -F ISPCP_INPUT 2>> "$LOGFILE" |
|---|
| | 121 | ${IPTABLES} -F ISPCP_OUTPUT 2>> "$LOGFILE" |
|---|
| | 122 | ${IPTABLES} -X ISPCP_INPUT 2>> "$LOGFILE" |
|---|
| | 123 | ${IPTABLES} -X ISPCP_OUTPUT 2>> "$LOGFILE" |
|---|
| | 124 | |
|---|
| | 125 | # Remove lock file |
|---|
| | 126 | rm $LFILE |
|---|
| | 127 | } |
|---|
| | 128 | |
|---|
| | 129 | case "$1" in |
|---|
| | 130 | start) |
|---|
| | 131 | log_daemon_msg "Starting $DESC" "$NAME" |
|---|
| | 132 | |
|---|
| | 133 | if [ -e "$LFILE" ]; then |
|---|
| | 134 | echo "" |
|---|
| | 135 | log_warning_msg "${NAME} is already started" >&2 |
|---|
| | 136 | else |
|---|
| | 137 | add_rules |
|---|
| | 138 | fi |
|---|
| | 139 | |
|---|
| | 140 | log_end_msg $? |
|---|
| | 141 | ;; |
|---|
| | 142 | stop) |
|---|
| | 143 | log_daemon_msg "Stopping $DESC" "$NAME" |
|---|
| | 144 | if [ ! -e "$LFILE" ]; then |
|---|
| | 145 | echo "" |
|---|
| | 146 | log_warning_msg "${NAME} is already stopped" >&2 |
|---|
| | 147 | else |
|---|
| | 148 | remove_rules |
|---|
| | 149 | fi |
|---|
| | 150 | |
|---|
| | 151 | log_end_msg $? |
|---|
| | 152 | ;; |
|---|
| | 153 | restart|force-reload) |
|---|
| | 154 | log_daemon_msg "Stopping $DESC" "$NAME" |
|---|
| | 155 | |
|---|
| | 156 | if [ ! -e "$LFILE" ]; then |
|---|
| | 157 | echo "" |
|---|
| | 158 | log_warning_msg "${NAME} is already stopped" >&2 |
|---|
| | 159 | else |
|---|
| | 160 | remove_rules |
|---|
| | 161 | log_end_msg $? |
|---|
| | 162 | [ -n "$DIETIME" ] && sleep "$DIETIME" |
|---|
| | 163 | fi |
|---|
| | 164 | |
|---|
| | 165 | log_daemon_msg "Starting $DESC" "$NAME" |
|---|
| | 166 | |
|---|
| | 167 | add_rules |
|---|
| | 168 | |
|---|
| | 169 | log_end_msg $? |
|---|
| | 170 | |
|---|
| | 171 | ;; |
|---|
| | 172 | status) |
|---|
| | 173 | log_daemon_msg "Checking status of $DESC" "$NAME" |
|---|
| | 174 | |
|---|
| | 175 | if [ ! -e "$LFILE" ]; then |
|---|
| | 176 | log_progress_msg "stopped" |
|---|
| | 177 | else |
|---|
| | 178 | log_progress_msg "started" |
|---|
| | 179 | fi |
|---|
| | 180 | |
|---|
| | 181 | echo "" |
|---|
| | 182 | ;; |
|---|
| | 183 | *) |
|---|
| | 184 | echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}" >&2 |
|---|
| | 185 | exit 1 |
|---|
| | 186 | ;; |
|---|
| | 187 | esac |
|---|
| | 188 | |
|---|
| | 189 | exit 0 |
|---|