From 458eb74c94de07953d8b6a12dfdbc1518871ce39 Mon Sep 17 00:00:00 2001 From: AhFei Date: Fri, 16 Jun 2023 23:32:52 +0800 Subject: [PATCH] add user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 可以自定义systemd中运行软件的用户,用户组同用户 --- one-touch.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/one-touch.sh b/one-touch.sh index a1a6621..e539990 100644 --- a/one-touch.sh +++ b/one-touch.sh @@ -11,7 +11,8 @@ WORKSPACE=${2} passwd=${3} uid=${4} server_address=${5} -test_or_not=${6} +user_name=${6} +test_or_not=${7} mkdir -p ${WORKSPACE} cd ${WORKSPACE} @@ -31,8 +32,8 @@ Description=ServerStatus-Rust Client After=network.target [Service] -User=1000 -Group=1000 +User=${user_name} +Group=${user_name} Environment="RUST_BACKTRACE=1" WorkingDirectory=${WORKSPACE} # EnvironmentFile=~/myserve/serverstatus/.env @@ -69,8 +70,8 @@ Description=ServerStatus-Rust Server After=network.target [Service] -User=1000 -Group=1000 +User=${user_name} +Group=${user_name} Environment="RUST_BACKTRACE=1" WorkingDirectory=${WORKSPACE} ExecStart=${WORKSPACE}/stat_server -c ${WORKSPACE}/config.toml