Skip to content

Commit

Permalink
semi-automated PD on raspbian scripts: fix the issue where 'mv' comma…
Browse files Browse the repository at this point in the history
…nd permanently removes the hook files
  • Loading branch information
yangsong-cnyn committed Sep 26, 2024
1 parent 702d768 commit 94e7b6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
17 changes: 7 additions & 10 deletions script/_dhcpv6_pd_ref
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

customise_dhcpcd_conf()
{
sudo tee /etc/dhcpcd.conf > /dev/null <<EOF
sudo tee /etc/dhcpcd.conf >/dev/null <<EOF
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
Expand Down Expand Up @@ -50,27 +50,24 @@ EOF
# EOF
# }

dhcp6_pd_ref_stop()
dhcpv6_pd_ref_stop()
{
if [[ -f "/etc/dhcpcd.conf.orig" ]]; then
sudo mv /etc/dhcpcd.conf.orig /etc/dhcpcd.conf
fi
# sudo systemctl restart dhcpcd
sudo rm /etc/dhcpcd.enter-hook /etc/dhcpcd.exit-hook
# sudo systemctl restart dhcpcd
sudo rm -f /etc/dhcpcd.enter-hook /etc/dhcpcd.exit-hook

}

dhcp6_pd_ref_start()
dhcpv6_pd_ref_start()
{
if [[ -f "/etc/dhcpcd.conf" ]]; then
sudo mv /etc/dhcpcd.conf /etc/dhcpcd.conf.orig
fi
customise_dhcpcd_conf
# Add dhcpcd.hooks
sudo mv ~/repo/script/reference-device/dhcpcd.enter-hook /etc/dhcpcd.enter-hook
sudo mv ~/repo/script/reference-device/dhcpcd.exit-hook /etc/dhcpcd.exit-hook
sudo chmod +x /etc/dhcpcd.enter-hook /etc/dhcpcd.exit-hook
sudo install -m 755 "$(dirname "$0")"/reference-device/dhcpcd.enter-hook /etc/dhcpcd.enter-hook
sudo install -m 755 "$(dirname "$0")"/reference-device/dhcpcd.exit-hook /etc/dhcpcd.exit-hook

}

dhcp6_pd_ref "$@"
10 changes: 5 additions & 5 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ install_packages_apt()
}

# dhcpv6 pd
with DHCPV6_PD_REF && if [[ "$PLATFORM" = "raspbian" ]]; then
with DHCPV6_PD_REF && if [[ $PLATFORM == "raspbian" ]]; then
sudo apt-get install --no-install-recommends -y dhcpcd
sudo mkdir -p /etc/systemd/system/dhcpcd.service.d
# allow edit system config file eg. /etc/radvd.conf
sudo tee /etc/systemd/system/dhcpcd.service.d/custom.conf > /dev/null <<EOF
sudo tee /etc/systemd/system/dhcpcd.service.d/custom.conf >/dev/null <<EOF
[Service]
ProtectSystem=false
EOF
# reload dhcpcd daemon to activate the custom.conf
sudo systemctl daemon-reload
sudo apt-get install --no-install-recommends -y radvd
# reload dhcpcd daemon to activate the custom.conf
sudo systemctl daemon-reload
sudo apt-get install --no-install-recommends -y radvd
fi

# network-manager
Expand Down

0 comments on commit 94e7b6e

Please sign in to comment.