DictXiong
dcd6f0c726
This reverts commit 01bc3762b2
.
Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
Reviewed-on: #87
26 lines
552 B
Bash
Executable File
26 lines
552 B
Bash
Executable File
#!/bin/bash
|
|
set -ex
|
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
|
|
adduser \
|
|
--disabled-password \
|
|
--home /home/ssh \
|
|
--gecos "jumpserver user ssh" \
|
|
ssh
|
|
|
|
usermod -p '*' ssh
|
|
|
|
insert_if_not_exist()
|
|
{
|
|
filename=$1
|
|
line=$2
|
|
if [ ! -f "$filename" ]; then
|
|
touch $filename
|
|
fi
|
|
grep -qxF -- "$line" "$filename" || echo "$line" >> "$filename"
|
|
}
|
|
|
|
insert_if_not_exist "/etc/crontabs/root" "*/5 * * * * cd \"$THIS_DIR\" && git pull && \"$THIS_DIR\"/jumpserver_cron.sh"
|
|
|
|
"$THIS_DIR"/jumpserver_cron.sh
|