mirror of
https://github.com/vimagick/dockerfiles.git
synced 2025-12-24 06:28:23 +01:00
add confd config
This commit is contained in:
35
etcd-arm/bin/shadowsocks.sh
Executable file
35
etcd-arm/bin/shadowsocks.sh
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# free shadowsocks
|
||||||
|
#
|
||||||
|
|
||||||
|
{
|
||||||
|
echo 'server,server_port,password,method,local_address,local_port,timeout'
|
||||||
|
curl -s 'http://www.ishadowsocks.com/' |
|
||||||
|
sed -n '/<section id="free"/,/section>/{/font/d;p}' |
|
||||||
|
grep -oP '(?<=<h4>).*(?=</h4>)' |
|
||||||
|
cut -d : -f 2 |
|
||||||
|
sed -e 'N;N;N;s/\n/,/g' \
|
||||||
|
-e 's/$/,127.0.0.1/' \
|
||||||
|
-e 's/$/,1080/' \
|
||||||
|
-e 's/$/,300/'
|
||||||
|
} |
|
||||||
|
csvjson |
|
||||||
|
jq -c 'map(
|
||||||
|
.fast_open = true |
|
||||||
|
with_entries(
|
||||||
|
.key as $key |
|
||||||
|
if ((["server_port", "local_port", "timeout"] | index($key)) == null)
|
||||||
|
then
|
||||||
|
.
|
||||||
|
else
|
||||||
|
(.value |= tonumber)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
)[]' |
|
||||||
|
while read line
|
||||||
|
do
|
||||||
|
server=$(echo "$line" | jq -r .server)
|
||||||
|
etcdctl -C 192.168.1.228:2379 set "/services/shadowsocks/$server" "$line"
|
||||||
|
done
|
||||||
|
|
||||||
7
etcd-arm/etc/confd/conf.d/shadowsocks.toml
Normal file
7
etcd-arm/etc/confd/conf.d/shadowsocks.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[template]
|
||||||
|
src = "shadowsocks.json.tmpl"
|
||||||
|
dest = "/etc/shadowsocks/client.json"
|
||||||
|
keys = [
|
||||||
|
"/services/shadowsocks"
|
||||||
|
]
|
||||||
|
#reload_cmd = "supervisorctl update"
|
||||||
6
etcd-arm/etc/confd/confd.toml
Normal file
6
etcd-arm/etc/confd/confd.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
backend = "etcd"
|
||||||
|
nodes = ["http://127.0.0.1:2379"]
|
||||||
|
confdir = "/etc/confd"
|
||||||
|
log-level = "info"
|
||||||
|
interval = 60
|
||||||
|
watch = true
|
||||||
16
etcd-arm/etc/confd/templates/shadowsocks.json.tmpl
Normal file
16
etcd-arm/etc/confd/templates/shadowsocks.json.tmpl
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{{ $base := "/services/shadowsocks" }}
|
||||||
|
{{ $name := index (ls $base) 2 }}
|
||||||
|
{{ with printf "%s/%s" $base $name | getv | json }}
|
||||||
|
|
||||||
|
{
|
||||||
|
"server": "{{ .server }}",
|
||||||
|
"server_port": {{ .server_port }},
|
||||||
|
"local_address": "{{ .local_address }}",
|
||||||
|
"local_port": {{ .local_port }},
|
||||||
|
"password": "{{ .password }}",
|
||||||
|
"method": "{{ .method }}",
|
||||||
|
"timeout": {{ .timeout }},
|
||||||
|
"fast_open": {{ .fast_open }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
9
etcd-arm/etc/systemd/system/confd.service
Normal file
9
etcd-arm/etc/systemd/system/confd.service
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Confd Daemon
|
||||||
|
After=etcd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/confd --config-file /etc/confd/confd.toml
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user