[Groonga-commit] droonga/droonga-http-server at e2fc408 [master] Extract code to register service for the version

Zurück zum Archiv-Index

YUKI Hiroshi null+****@clear*****
Fri Sep 26 15:53:46 JST 2014


YUKI Hiroshi	2014-09-26 15:53:46 +0900 (Fri, 26 Sep 2014)

  New Revision: e2fc408dfbbb8502c70fe1ddc3b88cdd13daabe5
  https://github.com/droonga/droonga-http-server/commit/e2fc408dfbbb8502c70fe1ddc3b88cdd13daabe5

  Message:
    Extract code to register service for the version

  Added files:
    install/centos/functions.sh
    install/debian/functions.sh
  Modified files:
    install.sh

  Modified: install.sh (+13 -34)
===================================================================
--- install.sh    2014-09-26 15:21:54 +0900 (77ab2c1)
+++ install.sh    2014-09-26 15:53:46 +0900 (c2f9daf)
@@ -34,11 +34,12 @@
 #     # curl https://raw.githubusercontent.com/droonga/droonga-http-server/master/install.sh | HOST=xxx.xxx.xxx.xxx ENGINE_HOST=xxx.xxx.xxx.xxx bash
 
 NAME=droonga-http-server
-SCRIPT_URL_BASE=https://raw.githubusercontent.com/droonga/$NAME
+DOWNLOAD_URL_BASE=https://raw.githubusercontent.com/droonga/$NAME
 REPOSITORY_URL=https://github.com/droonga/$NAME.git
 USER=$NAME
 GROUP=droonga
 DROONGA_BASE_DIR=/home/$USER/droonga
+TEMPDIR=/tmp/install-$NAME
 
 EXPRESS_DROONGA_REPOSITORY_URL=git://github.com/droonga/express-droonga.git#master
 
@@ -212,9 +213,7 @@ use_master_express_droonga() {
 }
 
 install_master() {
-  tempdir=/tmp/install-$NAME
-  mkdir $tempdir
-  cd $tempdir
+  cd $TEMPDIR
 
   if [ -d $NAME ]
   then
@@ -233,11 +232,11 @@ install_master() {
   mv package.json.bak package.json
 }
 
-script_url() {
+download_url() {
   if [ "$VERSION" = "master" ]; then
-    echo "$SCRIPT_URL_BASE/master/$1"
+    echo "$DOWNLOAD_URL_BASE/master/$1"
   else
-    echo "$SCRIPT_URL_BASE/v$(installed_version)/$1"
+    echo "$DOWNLOAD_URL_BASE/v$(installed_version)/$1"
   fi
 }
 
@@ -248,7 +247,6 @@ installed_version() {
 
 
 # ====================== for Debian/Ubuntu ==========================
-
 prepare_environment_in_debian() {
   apt-get update
   apt-get -y upgrade
@@ -258,23 +256,11 @@ prepare_environment_in_debian() {
     apt-get install -y git
   fi
 }
-
-register_service_in_debian() {
-  pid_dir=/var/run/$NAME
-  mkdir -p $pid_dir
-  chown -R $USER:$GROUP $pid_dir
-
-  curl -o /etc/init.d/$NAME $(script_url "install/debian/$NAME")
-  chmod +x /etc/init.d/$NAME
-  update-rc.d $NAME defaults
-}
-
 # ====================== /for Debian/Ubuntu =========================
 
 
 
 # ========================= for CentOS 7 ============================
-
 prepare_environment_in_centos() {
   if ! exist_yum_repository epel; then
     # epel-release is not installed, so install it.
@@ -294,24 +280,13 @@ prepare_environment_in_centos() {
     yum -y install git
   fi
 }
-
-register_service_in_centos() {
-  #TODO: we should migrate to systemd in near future...
-
-  pid_dir=/run/$NAME
-  mkdir -p $pid_dir
-  chown -R $USER:$GROUP $pid_dir
-
-  curl -o /etc/rc.d/init.d/$NAME $(script_url "install/centos/$NAME")
-  chmod +x /etc/rc.d/init.d/$NAME
-  /sbin/chkconfig --add $NAME
-}
-
 # ========================= /for CentOS 7 ===========================
 
 
 
 install() {
+  mkdir -p $TEMPDIR
+
   prepare_environment
 
   echo ""
@@ -323,13 +298,17 @@ install() {
     npm install -g droonga-http-server
   fi
 
+  curl -o $TEMPDIR/functions.sh $(download_url "install/$PLATFORM/functions.sh")
+  source $TEMPDIR/functions.sh
+
   prepare_user
 
   setup_configuration_directory
 
   echo ""
   echo "Registering $NAME as a service..."
-  register_service_in_$PLATFORM
+  # this function is defined by the downloaded "functions.sh"!
+  register_service $NAME $USER $GROUP
 
   echo ""
   echo "Successfully installed $NAME."

  Added: install/centos/functions.sh (+30 -0) 100755
===================================================================
--- /dev/null
+++ install/centos/functions.sh    2014-09-26 15:53:46 +0900 (60b7b2f)
@@ -0,0 +1,30 @@
+# Copyright (C) 2014 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+register_service() {
+  NAME=$1
+  USER=$2
+  GROUP=$3
+
+  #TODO: we should migrate to systemd in near future...
+
+  pid_dir=/run/$NAME
+  mkdir -p $pid_dir
+  chown -R $USER:$GROUP $pid_dir
+
+  curl -o /etc/rc.d/init.d/$NAME $(download_url "install/centos/$NAME")
+  chmod +x /etc/rc.d/init.d/$NAME
+  /sbin/chkconfig --add $NAME
+}

  Added: install/debian/functions.sh (+28 -0) 100755
===================================================================
--- /dev/null
+++ install/debian/functions.sh    2014-09-26 15:53:46 +0900 (922434d)
@@ -0,0 +1,28 @@
+# Copyright (C) 2014 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+register_service() {
+  NAME=$1
+  USER=$2
+  GROUP=$3
+
+  pid_dir=/var/run/$NAME
+  mkdir -p $pid_dir
+  chown -R $USER:$GROUP $pid_dir
+
+  curl -o /etc/init.d/$NAME $(download_url "install/debian/$NAME")
+  chmod +x /etc/init.d/$NAME
+  update-rc.d $NAME defaults
+}
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index