mirror of
https://github.com/samuelhbne/server-xray.git
synced 2025-12-17 04:14:40 +03:00
JSON merge support
This commit is contained in:
@@ -85,6 +85,7 @@ server-xray <server-options>
|
||||
-r|--request-domain <domain-name> Domain name to request for letsencrypt cert
|
||||
-c|--cert-home <cert-home-dir> Reading TLS certs from folder <cert-home-dir>/<domain-name>/
|
||||
-i|--stdin Read config from STDIN instead of auto generation
|
||||
-j|--json '{"log":{"loglevel":"info"}' Json snippet to merge into the config
|
||||
-d|--debug Start in debug mode with verbose output
|
||||
```
|
||||
|
||||
|
||||
26
run.sh
26
run.sh
@@ -33,7 +33,7 @@ usage() {
|
||||
echo " -r|--request-domain <domain-name> Domain name to request for letsencrypt cert"
|
||||
echo " -c|--cert-home <cert-home-dir> Reading TLS certs from folder <cert-home-dir>/<domain-name>/"
|
||||
echo " -i|--stdin Read config from STDIN instead of auto generation"
|
||||
echo " -j|--json Extra json snippet needs to merge into config"
|
||||
echo " -j|--json '{"log":{"loglevel":"info"}' Json snippet to merge into the config"
|
||||
echo " -d|--debug Start in debug mode with verbose output"
|
||||
}
|
||||
|
||||
@@ -150,18 +150,6 @@ fi
|
||||
|
||||
echo '{"log":{"loglevel":"warning"}, "inbounds":[], "outbounds":[{"protocol":"freedom"}]}' |jq .|sponge $XCONF
|
||||
|
||||
if [ -n "${INJECT}" ]; then
|
||||
for JSON_IN in "${INJECT[@]}"
|
||||
do
|
||||
echo "${JSON_IN}"|jq -ec >/tmp/merge.json
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Invalid json ${JSON_IN}"
|
||||
exit 1
|
||||
fi
|
||||
jq -s '.[0] * .[1]' $XCONF /tmp/merge.json |sponge $XCONF
|
||||
done
|
||||
fi
|
||||
|
||||
xopt="xconf=$XCONF"
|
||||
xopt="$xopt,certhome=$CERTHOME"
|
||||
for uopt in "${UOPT[@]}"
|
||||
@@ -208,6 +196,18 @@ if [ -n "${SVCMD}" ]; then
|
||||
nginx;
|
||||
fi
|
||||
|
||||
if [ -n "${INJECT}" ]; then
|
||||
for JSON_IN in "${INJECT[@]}"
|
||||
do
|
||||
echo "${JSON_IN}"|jq -ec >/tmp/merge.json
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Invalid json ${JSON_IN}"
|
||||
exit 1
|
||||
fi
|
||||
jq -s '.[0] * .[1]' $XCONF /tmp/merge.json |sponge $XCONF
|
||||
done
|
||||
fi
|
||||
|
||||
exec /usr/local/bin/xray -c $XCONF
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user