YUKI Piro Hiroshi
null+****@clear*****
Sun Sep 7 23:44:50 JST 2014
YUKI "Piro" Hiroshi 2014-09-07 23:44:50 +0900 (Sun, 07 Sep 2014) New Revision: 73e153b15bb7086836c8718f9314f82260368b55 https://github.com/droonga/droonga-http-server/commit/73e153b15bb7086836c8718f9314f82260368b55 Message: Define common operations as functions Modified files: script/install.sh Modified: script/install.sh (+23 -9) =================================================================== --- script/install.sh 2014-09-07 23:36:42 +0900 (8a080bf) +++ script/install.sh 2014-09-07 23:44:50 +0900 (cbaefb2) @@ -19,7 +19,13 @@ USER=$NAME DROONGA_BASE_DIR=/home/$USER/droonga exist_user() { - grep "^$1:" /etc/passwd > /dev/null + id "$1" > /dev/null 2>&1 +} + +prepare_user() { + if ! exist_user $USER; then + useradd -m $USER + fi } setup_configuration_directory() { @@ -32,6 +38,17 @@ setup_configuration_directory() { chown -R $USER.$USER $DROONGA_BASE_DIR } +install_service_script() { + INSTALL_LOCATION=$1 + PLATFORM=$2 + DOWNLOAD_URL=$SCRIPT_URL/$PLATFORM/$NAME + if [ ! -e $INSTALL_LOCATION ] + then + curl -o $INSTALL_LOCATION $DOWNLOAD_URL + chmod +x $INSTALL_LOCATION + fi +} + install_in_debian() { # install droonga apt-get update @@ -39,14 +56,12 @@ install_in_debian() { apt-get install -y nodejs nodejs-legacy npm npm install -g droonga-http-server - exist_user $USER || useradd -m $USER - + prepare_user + setup_configuration_directory debian # set up service - [ ! -e /etc/init.d/$NAME ] && - curl -o /etc/init.d/$NAME $SCRIPT_URL/debian/$NAME - chmod +x /etc/init.d/$NAME + install_service_script /etc/rc.d/init.d/$NAME debian update-rc.d $NAME defaults } @@ -60,12 +75,11 @@ install_in_centos() { yum -y install npm npm install -g droonga-http-server - exist_user $USER || useradd -m $USER + prepare_user setup_configuration_directory centos - [ ! -e /etc/rc.d/init.d/$NAME ] && - curl -o /etc/rc.d/init.d/$NAME $SCRIPT_URL/centos/$NAME + install_service_script /etc/rc.d/init.d/$NAME centos /sbin/chkconfig --add $NAME } -------------- next part -------------- HTML����������������������������... 下载