#!/bin/bash set -e # NOTE: App is installed to /opt/$APP_COMPARTMENT/$APP_MODULE APP_COMPARTMENT="nsq-server" APP_MODULE="nsq-server" if [ $UID -ne 0 ]; then echo "请用root用户运行当前脚本 (su root)" && exit 1 fi if [ -r /opt/$APP_COMPARTMENT/$APP_MODULE ];then echo "/opt/$APP_COMPARTMENT/$APP_MODULE 文件夹已存在,请重命名旧版本文件后再尝试" exit fi root_dir=/opt/$APP_COMPARTMENT if [ ! -d "$root_dir" ]; then mkdir -p $root_dir fi tar zxf ./$APP_MODULE.tar.gz -C $root_dir cp -f systemd.service /etc/systemd/system/$APP_MODULE.service if [ ! -r /opt/$APP_COMPARTMENT/$APP_MODULE ];then echo "安装失败!" exit else echo "安装成功!" fi chmod +x /opt/$APP_COMPARTMENT/$APP_MODULE/*.sh chmod +x /opt/$APP_COMPARTMENT/$APP_MODULE/bin/* systemctl daemon-reload systemctl enable $APP_MODULE systemctl start $APP_MODULE echo "$APP_MODULE 已启动"