#!/bin/bash set -ex THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) adduser \ --disabled-password \ --home /home/ssh \ 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/crontab" "*/5 0 0 0 0 cd \"$THIS_DIR\" && git pull && \"$THIS_DIR\"/jumpserver_cron.sh"