Merge pull request #572 from Aryangh1379/Hiddify-develop

Hiddify develop
This commit is contained in:
Hiddify
2024-02-27 15:15:28 +03:30
committed by GitHub

View File

@@ -2,8 +2,56 @@
cd "$(dirname "$0")"
export LD_LIBRARY_PATH=usr/lib
if [ "$1" == "HiddifyService" ];then
exec ./$@
else
exec ./hiddify $@
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} [-s | -v | -h ] ...
start Hiddify or HiddifyService, when no parameter is given, Hiddify is executed.
-h display this help and exit
-s start|stop start/stop HiddifyService.
-v show version
EOF
}
show_version() {
printf "Hiddify version "
jq .version <./data/flutter_assets/version.json
}
# Initialize variables:
service=0 #declare -i service
OPTIND=1
# Resetting OPTIND is necessary if getopts was used previously in the script.
# It is a good idea to make OPTIND local if you process options in a function.
# if no arg is provided, execute hiddify app
[[ $# == 0 ]] && exec hiddify
# processing arguments
while getopts s:vh opt; do
case $opt in
h)
show_help
exit 0
;;
v) show_version
exit 0
;;
s) action="$OPTARG"
((service++))
;;
*)
show_help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))" # Discard the options and sentinel --
# argument -s is given, do HiddfyService
if [[ "$service" == 1 ]]; then
if [[ "$action" =~ start|stop ]]; then
exec ./HiddifyService "$action"
fi
fi