実行するのが一般的であるgit pull
上DEV /ステージング/運用サーバー(複数可)。私は頻繁に自分でそうします。Linuxを実行している本番サーバーで1日にほぼ100回gitpullを実行します。
それを改善するためのスクリプトを作成する時が来たと思います。
pull.shはこれらの3つのコマンドを実行します
ここでpull.shを作成してみました
#!/bin/bash
function pull {
git pull
password
service nginx reload
}
pull ;
結果
私が持っているスクリプトを実行した後、私はまだパスワードを入力するように促されました。
ヒント/ヘルプ/提案は大歓迎です!
expect
スクリプトを使用してgit認証を操作できます。
#!/usr/bin/expect -f
spawn git pull
expect "ass"
send "your_password\r"
interact
「ass」テキスト(「Password」、「password」、「passphrase」に一致)を待ってから、パスワードを送信します。
そのスクリプトは、サーバーを再起動する別のbashスクリプトから呼び出すことができます。
# Call script directly since the shell knows that it should run it with
# expect tool because of the first script line "#!/usr/bin/expect -f"
./git-pull-helper-script.sh
# Without the first line "#!/usr/bin/expect -f" the file with commands
# may be sent explicitly to 'expect':
expect file-with-commands
# Restart server
service nginx reload
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加