Skip to content

Instantly share code, notes, and snippets.

@amaotone
Last active March 15, 2017 12:16
Show Gist options
  • Select an option

  • Save amaotone/916988bb31b22ad09484555470944972 to your computer and use it in GitHub Desktop.

Select an option

Save amaotone/916988bb31b22ad09484555470944972 to your computer and use it in GitHub Desktop.
GitBucketを立ち上げたり止めたりアップデートしたりします。
#!/bin/bash
#
# GitBucket helper (start, stop, and update)
# Amane Suzuki
name=$(basename $0)
usage() {
cat <<EOT
Usage:
${name} [options]
Overview:
Launch GitBucket
Options:
-h Show this message
-u Update gitbucket
-k Kill gitbucket (without relaunch)
EOT
}
kill_() {
pkill -f "gitbucket.war"
echo "existing gitbucket stopped"
}
launch() {
nohup java -jar gitbucket.war --port=8888 --prefix=/gitbucket > out.log 2> err.log &
echo "gitbucket launched"
}
update() {
mv gitbucket.war gitbucket.war.bak
local link=$(curl -s https://api.github.com/repos/gitbucket/gitbucket/releases \
| jq -r '.[0].assets[] | select(.name=="gitbucket.war") | .browser_download_url')
wget ${link} -O gitbucket.war
echo "gitbucket updated"
}
while getopts ":kuh" opts
do
case $opts in
h|\?)
usage
exit 1
;;
u)
kill_
update
;;
k)
kill_
exit 0
;;
esac
done
launch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment