Update add-tailscale-lxc.sh

added a menu that enables you to choose the specific container where you want to install Tailscale.
This commit is contained in:
tteckster 2023-09-06 14:24:44 -04:00 committed by GitHub
parent b3777abadc
commit 186230591b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 3 deletions

View File

@ -17,9 +17,8 @@ EOF
}
clear
header_info
echo -e "\e[1;33mThis script will add Tailscale to an existing LXC Container ONLY\e[0m"
while true; do
read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn
read -p "This will add Tailscale to an existing LXC Container ONLY. Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
@ -48,7 +47,24 @@ function msg() {
echo -e "$TEXT"
}
CTID=$1
NODE=$(hostname)
while read -r line; do
TAG=$(echo "$line" | awk '{print $1}')
ITEM=$(echo "$line" | awk '{print substr($0,36)}')
OFFSET=2
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi
CTID_MENU+=("$TAG" "$ITEM " "OFF")
done < <(pct list | awk 'NR>1')
while [ -z "${CTID:+x}" ]; do
CTID=$(whiptail --title "Containers on $NODE" --radiolist \
"\nSelect a container to add Tailscale to:\n" \
16 $(($MSG_MAX_LENGTH + 23)) 6 \
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
done
CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf
cat <<EOF >>$CTID_CONFIG_PATH
lxc.cgroup2.devices.allow: c 10:200 rwm