Skip to content

Commit a4b471d

Browse files
authored
Fix tailscale service
1 parent 149140d commit a4b471d

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.devcontainer/.codespace.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@ COPY --from=builder /go/bin/tailscaled /usr/sbin/tailscaled
2323
COPY --from=builder /go/bin/tailscale /usr/bin/tailscale
2424

2525
RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale
26+
27+
USER codespace
28+
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
29+
ENV SHELL=zsh
30+
RUN echo "alias gits='git status'" >> $HOME/.zshrc
31+
RUN echo "alias ls='ls -GFh'" >> $HOME/.zshrc
32+
ENV NVM_DIR="$HOME/.nvm"
33+
RUN echo ". ~/.nvm/nvm.sh" >> $HOME/.zshrc
34+
RUN sed -i 's/plugins=(git)/plugins=(git npm docker-compose docker)/' $HOME/.zshrc
35+
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
36+
RUN sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' $HOME/.zshrc
37+
RUN wget https://gist.githubusercontent.com/trumbitta/dc0c235832c5851813746d5886e40c56/raw/4663769f792bc9990b6b18242819b37a89a8ce53/.p10k.zsh -O $HOME/.p10k.zsh
38+
RUN echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> $HOME/.zshrc

.devcontainer/tailscaled

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
### BEGIN INIT INFO
4+
# Provides: tailscaled
5+
# Required-Start:
6+
# Required-Stop:
7+
# Default-Start:
8+
# Default-Stop:
9+
# Short-Description: Tailscale Mesh Wireguard VPN
10+
### END INIT INFO
11+
12+
set -e
13+
14+
# /etc/init.d/tailscale: start and stop the Tailscale VPN service
15+
16+
test -x /usr/sbin/tailscaled || exit 0
17+
18+
umask 022
19+
20+
. /lib/lsb/init-functions
21+
22+
# Are we running from init?
23+
run_by_init() {
24+
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
25+
}
26+
27+
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
28+
29+
case "$1" in
30+
start)
31+
log_daemon_msg "Starting Tailscale VPN" "tailscaled" || true
32+
if start-stop-daemon --start --quiet --oknodo --chuid 0:0 --pidfile /run/tailscaled.pid --background \
33+
--exec /usr/sbin/tailscaled -- --state=/var/lib/tailscale/tailscaled.state \
34+
--socket=/run/tailscale/tailscaled.sock --port 41641; then
35+
tailscale up --authkey=${TAILSCALE_AUTHKEY} --netfilter-mode=off
36+
log_end_msg 0 || true
37+
else
38+
log_end_msg 1 || true
39+
fi
40+
;;
41+
stop)
42+
log_daemon_msg "Stopping Tailscale VPN" "tailscaled" || true
43+
if start-stop-daemon --stop --quiet --oknodo --pidfile /run/tailscaled.pid --exec /usr/sbin/tailscaled; then
44+
log_end_msg 0 || true
45+
else
46+
log_end_msg 1 || true
47+
fi
48+
;;
49+
50+
status)
51+
status_of_proc -p /run/tailscaled.pid /usr/sbin/tailscaled tailscaled && exit 0 || exit $?
52+
;;
53+
54+
*)
55+
log_action_msg "Usage: /etc/init.d/tailscaled {start|stop|status}" || true
56+
exit 1
57+
esac
58+
59+
exit 0

0 commit comments

Comments
 (0)