Skip to content

Instantly share code, notes, and snippets.

@holysugar
Created December 21, 2017 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holysugar/16a8c8614a2f74b8ec848430aedfc074 to your computer and use it in GitHub Desktop.
Save holysugar/16a8c8614a2f74b8ec848430aedfc074 to your computer and use it in GitHub Desktop.
雰囲気で shell で書いた何か
#!/bin/bash
. ../functions/base.subr
install_once nginx
# install_once nginx_config
# install_once rbenv
# ...
_file=${BASH_SOURCE:-$0}
_basedir=$(dirname $_file)
green()
{
echo "\033[32m$1\033[0m"
}
red()
{
echo "\033[31m$1\033[0m"
}
yellow()
{
echo "\033[33m$1\033[0m"
}
echoskip()
{
green "[SKIP] $1"
}
install_once()
{
local name=$1
shift
. ${_basedir}/$name.subr
checkinstalled_$name "$@"
case $? in
0 )
green "===> [SKIP] $name already installed"
;;
127 )
red "===> checkinstalled_$name is not defined."
;;
* )
yellow "===> [INSTALL] $name"
install_$name "$@"
;;
esac
}
atexit()
{
_atexit_list="${_atexit_list} $1"
}
_atexit()
{
for i in ${_atexit_list}; do
$i
done
}
trap _atexit EXIT
checkinstalled_nginx()
{
nginx -v 2>&1 | grep nginx/${required_nginx_version} >/dev/null
}
install_nginx()
{
cat <<EOF > /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/\$basearch/
gpgcheck=0
enabled=1
EOF
yum install nginx -y
systemctl enable nginx
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment