12345678910111213141516171819202122232425 |
- #!/bin/bash
- # test with sudo runuser -u root bash {script_path}
- set -x
- name=$(whoami)
- echo "start $0 with $name"
- exec="/usr/share/uosbrowser/uosbrowser"
- exec1=$(which browser)
- exec2=$(which uos-browser)
- if [ "${exec1}" != "" ]; then
- exec="/usr/share/browser/browser"
- fi
- echo "run $exec"
- # get env
- pid=$(pgrep startdde)
- # source env from $pid
- # shellcheck disable=SC1090
- . <(xargs -0 bash -c 'printf "export %q\n" "$@"' -- </proc/$pid/environ)
- name=$(ps -o uname= -p "${pid}")
- echo "run in $name"
- if [ $# -eq 0 ]; then
- runuser -u "$name" -- bash -c "$exec &" & #无参数执行
- else
- runuser -u "$name" -- bash -c "$exec $* &" & # 将参数传递给命令
- fi
- exit $?
|