我让 SSH 在脚本中执行一些命令,如下所示:
#!/bin/bash
REMOTEUSER=$1
REMOTEHOST=$2
newVh=$3
ssh "$REMOTEUSER"@"$REMOTEHOST" << EOF
cd
if [ ! -d "/data/web/someDirectory" ]
then
echo -e "There is no vhost setup for someDirectory"
exit 1
fi
if [ ! -d "git" ]
then
echo -e "Home git directory not found. Creating it now."
mkdir git
fi
if [ ! -d "git/$newVh.git" ]
then
echo -e "Bare git repository not found for $new. Creating it now."
mkdir git/"$newVh".git
git init --bare git/"$newVh".git
fi
EOF
Run Code Online (Sandbox Code Playgroud)
哪个工作正常并且做我想要的。我正在尝试检查compass …