Skip to content

Commit

Permalink
Merge pull request #70 from SierraSoftworks/fix/issue-69
Browse files Browse the repository at this point in the history
feat: Add support for propagating TAILSCALED_FLAGS from tailscale-env for UniFi 2.x+ installs
  • Loading branch information
notheotherben authored Nov 1, 2023
2 parents 4fcda66 + a1750db commit 1596599
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 15 additions & 4 deletions package/unios_2.x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,21 @@ _tailscale_install() {
echo "Installing Tailscale ${tailscale_version}..."
apt install -y tailscale="${tailscale_version}"

echo "Configuring Tailscale to use userspace networking..."
sed -i 's/FLAGS=""/FLAGS="--state \/data\/tailscale\/tailscaled.state --tun userspace-networking"/' /etc/default/tailscaled || {
echo "Failed to configure Tailscale to use userspace networking"
echo "Check that the file /etc/default/tailscaled exists and contains the line FLAGS=\"--state /data/tailscale/tailscale.state --tun userspace-networking\"."
# Load the tailscale-env file to discover the flags which are required to be set
# shellcheck source=package/tailscale-env
. "${TAILSCALE_ROOT}/tailscale-env"

echo "Configuring Tailscale port..."
sed -i "s/PORT=\"[^\"]*\"/PORT=\"${PORT:-41641}\"/" /etc/default/tailscaled || {
echo "Failed to configure Tailscale port"
echo "Check that the file /etc/default/tailscaled exists and contains the line PORT=\"${PORT:-41641}\"."
exit 1
}

echo "Configuring Tailscaled startup flags..."
sed -i "s/FLAGS=\"[^\"]*\"/FLAGS=\"--state \/data\/tailscale\/tailscaled.state ${TAILSCALED_FLAGS}\"/" /etc/default/tailscaled || {
echo "Failed to configure Tailscaled startup flags"
echo "Check that the file /etc/default/tailscaled exists and contains the line FLAGS=\"--state /data/tailscale/tailscale.state ${TAILSCALED_FLAGS}\"."
exit 1
}

Expand Down
3 changes: 3 additions & 0 deletions tests/install.2.x.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ esac
EOF
chmod +x "${WORKDIR}/systemctl"

cp "${PACKAGE_ROOT}/tailscale-env" "${WORKDIR}/tailscale-env"

"${ROOT}/package/manage.sh" install; assert "Tailscale installer should run successfully"

cat "${WORKDIR}/apt.args"
cat "${WORKDIR}/sed.args"

assert_contains "$(head -n 1 "${WORKDIR}/apt.args")" "update" "The apt command should be called to update the package list"
assert_contains "$(head -n 2 "${WORKDIR}/apt.args" | tail -n 1)" "install -y tailscale" "The apt command should be called with the command to install tailscale file"
Expand Down

0 comments on commit 1596599

Please sign in to comment.