阿里云的一个安装脚本

#!/bin/bash

if [ `uname -m` = "x86_64" ]; then
    ARCH="linux64"
else
    ARCH="linux32"
fi

AEGIS_UPDATE_SITE="http://update.aegis.aliyun.com/download"
AEGIS_INSTALL_DIR="/usr/local/aegis"

install_aegis() {
    killall -9 aegis_update
    killall -9 aegis_cli
    if [ -d ${AEGIS_INSTALL_DIR} ];then
        rm -rf ${AEGIS_INSTALL_DIR}
    fi
    mkdir -p "${AEGIS_INSTALL_DIR}/aegis_client"
    mkdir -p "${AEGIS_INSTALL_DIR}/aegis_update"

   
    wget "${AEGIS_UPDATE_SITE}/$ARCH/update_00_06/aegis_update" -O "${AEGIS_INSTALL_DIR}/aegis_update/aegis_update" -T 120
    if [ $? != 0 ]; then
        echo "wget aegis_update error" 1>&2
        exit 1
    fi
    wget "${AEGIS_UPDATE_SITE}/$ARCH/update_00_06/agx_update.cfg" -O "${AEGIS_INSTALL_DIR}/aegis_update/agx_update.cfg" -T 120
    if [ $? != 0 ]; then
        echo "wget agx_update.cfg error" 1>&2
        exit 1
    fi
   
    chmod +x "${AEGIS_INSTALL_DIR}/aegis_update/aegis_update"
    echo "aegis_00_19" > ${AEGIS_INSTALL_DIR}/aegis_update/up_cmd.txt
}

install_service(){
    wget "${AEGIS_UPDATE_SITE}/aegis" -O /etc/init.d/aegis
    if [ $? != 0 ]; then
        echo "wget aegis error" 1>&2
        exit 1
    fi
   
    chmod +x /etc/init.d/aegis

    rm -f /etc/rc2.d/S80aegis
    rm -f /etc/rc3.d/S80aegis
    rm -f /etc/rc4.d/S80aegis
    rm -f /etc/rc5.d/S80aegis

    ln -s /etc/init.d/aegis /etc/rc2.d/S80aegis >/dev/null 2>&1
    ln -s /etc/init.d/aegis /etc/rc3.d/S80aegis >/dev/null 2>&1
    ln -s /etc/init.d/aegis /etc/rc4.d/S80aegis >/dev/null 2>&1
    ln -s /etc/init.d/aegis /etc/rc5.d/S80aegis >/dev/null 2>&1
}

uninstall_service() {
    rm -f /etc/init.d/aegis
    rm -f /etc/rc2.d/S80aegis
    rm -f /etc/rc3.d/S80aegis
    rm -f /etc/rc4.d/S80aegis
    rm -f /etc/rc5.d/S80aegis
}

if [ `id -u` -ne "0" ]; then
    echo "ERROR: This script must be run as root." 1>&2
    exit 1
fi

install_aegis
install_service
service aegis start

echo "Aegis install successful"
exit 0

你可能感兴趣的:(Shell)