1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2025-01-04 03:48:55 +02:00

add confd config

This commit is contained in:
kev 2015-10-01 12:27:32 +08:00
parent d57f056447
commit f719fc14f7
5 changed files with 73 additions and 0 deletions

35
etcd-arm/bin/shadowsocks.sh Executable file
View 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

View File

@ -0,0 +1,7 @@
[template]
src = "shadowsocks.json.tmpl"
dest = "/etc/shadowsocks/client.json"
keys = [
"/services/shadowsocks"
]
#reload_cmd = "supervisorctl update"

View File

@ -0,0 +1,6 @@
backend = "etcd"
nodes = ["http://127.0.0.1:2379"]
confdir = "/etc/confd"
log-level = "info"
interval = 60
watch = true

View 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 }}

View 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