[Groonga-commit] droonga/droonga-engine at db8c8ee [master] Extract codes to register service for the version

Zurück zum Archiv-Index

YUKI Hiroshi null+****@clear*****
Fri Sep 26 15:49:58 JST 2014


YUKI Hiroshi	2014-09-26 15:49:58 +0900 (Fri, 26 Sep 2014)

  New Revision: db8c8eeb15329230882914e6a0d0dbb7c885b50d
  https://github.com/droonga/droonga-engine/commit/db8c8eeb15329230882914e6a0d0dbb7c885b50d

  Message:
    Extract codes to register service for the version

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

  Modified: install.sh (+15 -37)
===================================================================
--- install.sh    2014-09-26 15:22:20 +0900 (34290cd)
+++ install.sh    2014-09-26 15:49:58 +0900 (cdc73c0)
@@ -34,16 +34,17 @@
 #     # curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | HOST=xxx.xxx.xxx.xxx bash
 
 NAME=droonga-engine
-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
 
 : ${VERSION:=release}
 : ${HOST:=Auto Detect}
 
-REQUIRED_COMMANDS=gem
+REQUIRED_COMMANDS=curl gem
 [ "$VERSION" = "master" ] &&
   REQUIRED_COMMANDS="$REQUIRED_COMMANDS git"
 
@@ -160,11 +161,11 @@ determine_hostname() {
   return 1
 }
 
-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
 }
 
@@ -194,9 +195,7 @@ install_rroonga() {
 install_master() {
   gem install bundler --no-ri --no-rdoc
 
-  tempdir=/tmp/install-$NAME
-  mkdir $tempdir
-  cd $tempdir
+  cd $TEMPDIR
 
   if [ -d $NAME ]
   then
@@ -219,7 +218,6 @@ install_master() {
 
 
 # ====================== for Debian/Ubuntu ==========================
-
 prepare_environment_in_debian() {
   apt-get update
   apt-get -y upgrade
@@ -229,23 +227,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() {
   yum update
   yum -y groupinstall development
@@ -255,26 +241,14 @@ 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() {
-  echo "Preparing the environment..."
-  prepare_environment_in_$PLATFORM
+  mkdir -p $TEMPDIR
+
+  prepare_environment
 
   echo ""
   if [ "$VERSION" = "master" ]; then
@@ -285,13 +259,17 @@ install() {
     gem install droonga-engine --no-rdoc --no-ri
   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
 
   echo ""
   echo "Successfully installed $NAME."

  Added: install/centos/functions.sh (+30 -0) 100755
===================================================================
--- /dev/null
+++ install/centos/functions.sh    2014-09-26 15:49:58 +0900 (d73de01)
@@ -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 $(script_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:49:58 +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