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
|
-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>/
|
-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
|
-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
|
-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 " -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 " -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 " -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"
|
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
|
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="xconf=$XCONF"
|
||||||
xopt="$xopt,certhome=$CERTHOME"
|
xopt="$xopt,certhome=$CERTHOME"
|
||||||
for uopt in "${UOPT[@]}"
|
for uopt in "${UOPT[@]}"
|
||||||
@@ -208,6 +196,18 @@ if [ -n "${SVCMD}" ]; then
|
|||||||
nginx;
|
nginx;
|
||||||
fi
|
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
|
exec /usr/local/bin/xray -c $XCONF
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user