1
0
forked from NASP/registry
registry/scripts/jumpserver_deploy.sh

24 lines
532 B
Bash
Raw Normal View History

2023-03-30 01:39:08 +08:00
#!/bin/bash
set -ex
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
2023-04-21 16:31:57 +08:00
adduser \
--disabled-password \
--home /home/ssh \
2023-04-21 16:46:37 +08:00
--gecos "jumpserver user ssh" \
2023-04-21 16:31:57 +08:00
ssh
2023-03-30 01:39:08 +08:00
2023-04-21 16:31:57 +08:00
insert_if_not_exist()
{
filename=$1
line=$2
if [ ! -f "$filename" ]; then
touch $filename
fi
grep -qxF -- "$line" "$filename" || echo "$line" >> "$filename"
}
2023-03-30 01:39:08 +08:00
insert_if_not_exist "/etc/crontabs/root" "*/5 * * * * cd \"$THIS_DIR\" && git pull && \"$THIS_DIR\"/jumpserver_cron.sh"
2023-04-21 17:12:36 +08:00
2023-04-21 17:23:04 +08:00
"$THIS_DIR"/jumpserver_cron.sh