startMixBrower.sh 671 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # test with sudo runuser -u root bash {script_path}
  3. set -x
  4. name=$(whoami)
  5. echo "start $0 with $name"
  6. exec="/usr/share/uosbrowser/uosbrowser"
  7. exec1=$(which browser)
  8. exec2=$(which uos-browser)
  9. if [ "${exec1}" != "" ]; then
  10. exec="/usr/share/browser/browser"
  11. fi
  12. echo "run $exec"
  13. # get env
  14. pid=$(pgrep startdde)
  15. # source env from $pid
  16. # shellcheck disable=SC1090
  17. . <(xargs -0 bash -c 'printf "export %q\n" "$@"' -- </proc/$pid/environ)
  18. name=$(ps -o uname= -p "${pid}")
  19. echo "run in $name"
  20. if [ $# -eq 0 ]; then
  21. runuser -u "$name" -- bash -c "$exec &" & #无参数执行
  22. else
  23. runuser -u "$name" -- bash -c "$exec $* &" & # 将参数传递给命令
  24. fi
  25. exit $?