b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh /etc/rc.common |
| 2 | |
| 3 | # Copyright 2020 Google LLC. |
| 4 | # Copyright (C) 2021 CZ.NIC z.s.p.o. (https://www.nic.cz/) |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | USE_PROCD=1 |
| 8 | START=80 |
| 9 | |
| 10 | start_service() { |
| 11 | local state_file |
| 12 | local port |
| 13 | local std_err std_out |
| 14 | |
| 15 | config_load tailscale |
| 16 | config_get_bool std_out "settings" log_stdout 1 |
| 17 | config_get_bool std_err "settings" log_stderr 1 |
| 18 | config_get port "settings" port 41641 |
| 19 | config_get state_file "settings" state_file /etc/tailscale/tailscaled.state |
| 20 | |
| 21 | /usr/sbin/tailscaled --cleanup |
| 22 | |
| 23 | procd_open_instance |
| 24 | procd_set_param command /usr/sbin/tailscaled |
| 25 | |
| 26 | # Set the port to listen on for incoming VPN packets. |
| 27 | # Remote nodes will automatically be informed about the new port number, |
| 28 | # but you might want to configure this in order to set external firewall |
| 29 | # settings. |
| 30 | procd_append_param command --port "$port" |
| 31 | procd_append_param command --state "$state_file" |
| 32 | |
| 33 | procd_set_param respawn |
| 34 | procd_set_param stdout "$std_out" |
| 35 | procd_set_param stderr "$std_err" |
| 36 | |
| 37 | procd_close_instance |
| 38 | } |
| 39 | |
| 40 | stop_service() { |
| 41 | /usr/sbin/tailscaled --cleanup |
| 42 | } |