mirror of https://github.com/lukechilds/umbrel.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
630 B
34 lines
630 B
4 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../../..)"
|
||
|
|
||
|
check_root () {
|
||
|
if [[ $UID != 0 ]]; then
|
||
|
echo "This script must be run as root"
|
||
|
exit 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
main () {
|
||
|
check_root
|
||
|
|
||
|
# Remove and then re-append iptables rule
|
||
|
rule=(PREROUTING \
|
||
|
--table nat \
|
||
|
--proto tcp \
|
||
|
--dport 80 \
|
||
|
--jump REDIRECT \
|
||
|
--to-port 8000)
|
||
|
if iptables --delete ${rule[@]} 2> /dev/null; then
|
||
|
echo "Removed existing iptables entry."
|
||
|
else
|
||
|
echo "No existing iptables entry found."
|
||
|
fi
|
||
|
iptables --append ${rule[@]}
|
||
|
echo "Appended new iptables entry."
|
||
|
}
|
||
|
|
||
|
main
|