Redis Common Management Scripts

Source: Internet
Author: User

#!/bin/sh#  Compile and install management redisapp=redisappname=redisappbase=/appappdir= $AppBase/$AppAppProg = $AppDir/bin/ redis-serverappconf= $AppDir/redis.confappsrcbase=/app/srcappsrcfile= $App-*.tar.*appsrcdir=$ (find $ appsrcbase -maxdepth 1 -name  "$AppSrcFile"  -type f 2> /dev/null  | sed -e  ' s/.tar.*$//'  -e  ' s/^.\///') appport=$ (grep  "^port"   $AppConf  | awk  ' {print $2} ') removeflag=0installflag=0#  get Pidfpid () {     apppid=$ (ps ax | grep  "$AppProg"  | grep -v  "grep"  | awk   ' {print $1} '  2> /dev/null)}#  query Status Fstatus () {    fpid     if [ ! -f  "$AppProg"  ]; then         echo  $AppName   not installed     else         echo  "$AppName   Installed"         if [ -z  "$AppPid"  ]; then             echo  $AppName   Not started          else            echo   $AppName   Running         fi    fi}#  Delete Fremove () {    fpid    removeflag=1    if [  -z  "$AppPid"  ]; then        if [ -d   "$AppDir"  ]; then            rm  -rf  $AppDir  && echo  Delete   $AppName          else            echo  "$AppName   Not Installed "   &NBsp;    fi    else        echo   $AppName   Running  && exit    fi}#  backup fbackup () {     day=$ (date +%y-%m-%d)     backupfile= $App. $Day .tgz     if [ -f  "$AppProg"  ]; then        cd $ appbase        tar zcvf  $BackupFile  --exclude=logs/*   $APP  --backup=numbered        [ $? -eq 0  ] && echo  "$AppName   Backup Success"  | |  echo  "$AppName   backup Failed"     else         echo  $AppName   Not installed     fi}#  install Finstall () {    fpid     installflag=1    if&nbSp [ -z  "$AppPid"  ]; then        test -f  "$ Appprog  && echo  $AppName   installed         [  $? -ne 0 ] && fupdate && fcpconf     else        echo  $AppName   Running      fi}#  Copy Configuration fcpconf () {    cp -vf --backup=numbered  $ScriptDir/ redis.conf  $AppConf}#  Update fupdate () {    operate= "Update"     [   $InstallFlag  -eq 1 ] && operate= "Installation"     [ $ removeflag -ne 1 ] && fbackup    cd  $AppSrcBase     test -d  "$AppSrcDir"  && rm -rf  $AppSrcDir      tar zxf  $AppSrcFile  | |  tar jxf  $AppSrcFile  | |  tar Jxf  $AppSrcFile     cd  $AppSrcDir     make  prefix= $AppDir  install    if [ $? -eq 0 ]; then         echo  "$AppName   $Operate Success"      else        echo  "$AppName   $Operate failed"          exit 1    fi}#  start Fstart () {     fpid    if [ -n  "$AppPid"  ]; then         echo  $AppName   Running     else          $AppProg   $AppConf  && echo  "start   $AppName"  | |  echo  "$AppName   start failed"     fi}#  stop Fstop () { &Nbsp;  fpid    if [ -n  "$AppPid"  ]; then          $AppDir/bin/redis-cli -p  $AppPort  shutdown &&  echo  "Stop   $AppName"  | |  echo  $AppName   Stop failure     else         echo  $AppName   Not started     fi}#  restart Frestart () {    fpid     [ -n  "$AppPid"  ] && fstop && sleep  1    fstart}#  Terminate Process Fkill () {    fpid     if [ -n  "$AppPid"  ]; then        kill -9   $AppPid  && echo  "Stop   $AppName   process"  | |  echo    Terminate   $AppName   process failure     else         echo  "$AppName   process not running"     fi}scriptdir=$ (cd $ (dirname $0);  PWD) scriptfile=$ (basename $0) case  "$"  in     "Install"    )  finstall;;      "Update"     )  fupdate;;      "Reinstall"  )  fremove && finstall;;      "Remove"     )  fremove;;      "Backup"     )  fbackup;;      "Start"      )  fstart;;      "Stop"       )  fstop;;      "Restart"    )  frestart;;      "status"     )  fstatus;;      "cpconf"     )  fcpconf;;      "Kill"       )  fkill;;     *           )     echo  "$ScriptFile  install               Installation   $AppName     echo  $ScriptFile  update                 update   $AppName "    echo   "$ScriptFile  reinstall             Reload   $AppName     echo  $ScriptFile  remove                 Delete   $AppName "    echo " $ scriptfile backup                 Backup   $AppName     echo  $ScriptFile  start                  start   $AppName "    echo " $ScriptFile  stop                   Stop   $AppName "    echo " $ScriptFile  restart                restart   $AppName     echo  $ScriptFile  status                Enquiry   $AppName   Status     echo  $ScriptFile  cpconf                 copy   $AppName   configuration      echo  "$ScriptFile  kill                   termination   $AppName   Process "    ;; Esac


This article is from the "Pine" blog, be sure to keep this source http://dongsong.blog.51cto.com/916653/1649590

Redis Common Management Scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.