SHIMODA Piro Hiroshi
null+****@clear*****
Mon Sep 29 01:46:22 JST 2014
SHIMODA "Piro" Hiroshi 2014-09-29 01:46:22 +0900 (Mon, 29 Sep 2014) New Revision: 48bbfc14b8fd9ce14ff5075b05fef7069a8a08db https://github.com/droonga/droonga-http-server/commit/48bbfc14b8fd9ce14ff5075b05fef7069a8a08db Message: Extract codes to detect platform and root Modified files: install.sh Modified: install.sh (+29 -10) =================================================================== --- install.sh 2014-09-26 16:06:18 +0900 (4ce3cfc) +++ install.sh 2014-09-29 01:46:22 +0900 (f9ec6fe) @@ -56,6 +56,29 @@ case $(uname) in *) sed="sed -r" ;; esac +ensure_root() { + if [ "$EUID" != "0" ]; then + echo "You must run this script as the root." + exit 1 + fi +} + +guess_platform() { + if [ -e /etc/debian_version ] || [ -e /etc/debian_release ]; then +# if lsb_release -i | grep --quiet Ubuntu; then +# echo "ubuntu" +# return 0 +# elif lsb_release -i | grep --quiet Debian; then + echo "debian" + return 0 +# fi + elif [ -e /etc/centos-release ]; then + echo "centos" + return 0 + fi + return 1 +} + exist_command() { type "$1" > /dev/null 2>&1 } @@ -316,18 +339,14 @@ install() { echo "Successfully installed $NAME." } -if [ "$EUID" != "0" ]; then - echo "You must run this script as the root." - exit 1 -elif [ -e /etc/debian_version ] || [ -e /etc/debian_release ]; then - PLATFORM=debian -elif [ -e /etc/centos-release ]; then - PLATFORM=centos -else - echo "Not supported platform. This script works only for Debian or CentOS." +eusure_root + +PLATFORM=$(guess_platform) +if [ "$PLATFORM" = "" ]; then + echo "Not supported platform." exit 255 fi -install $PLATFORM +install exit 0 -------------- next part -------------- HTML����������������������������...다운로드