removing open ports when sibling project removed
This commit is contained in:
@@ -5,10 +5,14 @@
|
||||
# A sibling is a git repository cloned into ~/.local/share/siblings/<name>.
|
||||
# If it has an install.sh, that runs once when the sibling is added.
|
||||
# Every `update` pulls each sibling and runs its update.sh, if it has one
|
||||
# (see updates.d/71-siblings.sh).
|
||||
# (see updates.d/71-siblings.sh). Ports listed in a sibling's firewall.conf
|
||||
# are opened when it's added and closed when it's removed.
|
||||
|
||||
SIBLINGS="$HOME/.local/share/siblings"
|
||||
|
||||
# Provides setup_firewall
|
||||
source "$HOME/.local/share/MiniServer/utils.sh"
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Usage: sibling [command]
|
||||
@@ -69,6 +73,15 @@ add_sibling() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Open the ports listed in the sibling's firewall.conf
|
||||
if [ -f "$dir/firewall.conf" ]; then
|
||||
echo "Applying $name's firewall.conf..."
|
||||
if ! setup_firewall; then
|
||||
echo "Some firewall rules could not be applied, see above. Fix the problem and run 'sibling add $url' again."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Confirm the install
|
||||
if [ -d "$dir/.git" ] && git -C "$dir" rev-parse --verify --quiet HEAD > /dev/null; then
|
||||
echo "Installed $name at $dir ($(git -C "$dir" log -1 --format='%h %s'))."
|
||||
@@ -105,6 +118,8 @@ remove_sibling() {
|
||||
case "$response" in
|
||||
[yY][eE][sS]|[yY])
|
||||
rm -rf "${SIBLINGS:?}/$name"
|
||||
# Close the ports only this sibling's firewall.conf asked for
|
||||
setup_firewall || echo "Some firewall rules could not be updated, see above. 'update' will retry."
|
||||
echo "Removed $name. Anything its install.sh set up outside that folder is still there."
|
||||
;;
|
||||
*)
|
||||
|
||||
Reference in New Issue
Block a user