1 Star 0 Fork 0

churchill/adbyby

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
jetbrains_license_server_init.sh 4.68 KB
一键复制 编辑 原始数据 按行查看 历史
churchill 提交于 2017-12-24 15:28 . 修正初始化脚本
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================
# System Required: CentOS/Debian/Ubuntu
# Description: ADbyby
# Version: 1.0.1
# Author: Toyo
# Blog: https://doub.io/adbyby-jc2/
#=================================================
file="/usr/local/bin"
jetbrains_file="/usr/local/bin/jetbrains"
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"
#检查系统
check_sys(){
if [[ -f /etc/redhat-release ]]; then
release="centos"
elif cat /etc/issue | grep -q -E -i "debian"; then
release="debian"
elif cat /etc/issue | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -q -E -i "debian"; then
release="debian"
elif cat /proc/version | grep -q -E -i "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
release="centos"
fi
bit=`uname -m`
}
check_installed_status(){
[[ ! -e ${jetbrains_file} ]] && echo -e "${Error} jetbrains 没有安装,请检查 !" && exit 1
}
check_pid(){
PID=`ps -ef| grep "jetbrains"| grep -v grep| grep -v ".sh"| grep -v "init.d"| grep -v "service"| awk '{print $2}'`
}
Download_jetbrains(){
cd ${file}
if [[ ${bit} == "x86_64" ]]; then
wget --no-check-certificate -O "jetbrains" "https://gitee.com/churking/adbyby/raw/master/IntelliJIDEALicenseServer_linux_amd64"
else
wget --no-check-certificate -O "jetbrains" "https://gitee.com/churking/adbyby/raw/master/IntelliJIDEALicenseServer_linux_amd32"
fi
[[ ! -e "jetbrains" ]] && echo -e "${Error} jetbrains 下载失败 !" && exit 1
chmod +x jetbrains
}
Service_jetbrains(){
if ! wget --no-check-certificate https://gitee.com/churking/adbyby/raw/master/jetbrains -O /etc/init.d/jetbrains; then
echo -e "${Error} jetbrains服务 管理脚本下载失败 !" && exit 1
fi
chmod +x /etc/init.d/jetbrains
update-rc.d -f jetbrains defaults
echo -e "${Info} jetbrains服务 管理脚本下载完成 !"
}
Install_jetbrains(){
[[ -e ${jetbrains_file} ]] && echo -e "${Error} 检测到 jetbrains 已安装 !" && exit 1
check_sys
echo -e "${Info} 开始下载/安装..."
Download_jetbrains
echo -e "${Info} 开始下载/安装 服务脚本(init)..."
Service_jetbrains
echo -e "${Info} 所有步骤 安装完毕,开始启动..."
Start_jetbrains
}
Start_jetbrains(){
check_installed_status
check_pid
[[ ! -z ${PID} ]] && echo -e "${Error} jetbrains 正在运行,请检查 !" && exit 1
service jetbrains start
}
Stop_jetbrains(){
check_installed_status
check_pid
[[ -z ${PID} ]] && echo -e "${Error} jetbrains 没有运行,请检查 !" && exit 1
service jetbrains stop
}
Restart_jetbrains(){
check_installed_status
check_pid
[[ ! -z ${PID} ]] && service jetbrains stop
service jetbrains start
}
Uninstall_jetbrains(){
check_installed_status
echo "确定要卸载 jetbrains ? (y/N)"
echo
read -p "(默认: n):" unyn
[[ -z ${unyn} ]] && unyn="n"
if [[ ${unyn} == [Yy] ]]; then
check_pid
[[ ! -z $PID ]] && kill -9 ${PID}
rm -rf ${file} && rm -rf /etc/init.d/jetbrains
if [[ ${release} = "centos" ]]; then
chkconfig --del jetbrains
else
update-rc.d -f jetbrains remove
fi
echo && echo "jetbrains 卸载完成 !" && echo
else
echo && echo "卸载已取消..." && echo
fi
}
echo && echo -e "请输入一个数字来选择选项
${Green_font_prefix}1.${Font_color_suffix} 安装 jetbrains
${Green_font_prefix}2.${Font_color_suffix} 卸载 jetbrains
————————————
${Green_font_prefix}3.${Font_color_suffix} 启动 jetbrains
${Green_font_prefix}4.${Font_color_suffix} 停止 jetbrains
${Green_font_prefix}5.${Font_color_suffix} 重启 jetbrains
————————————" && echo
if [[ -e ${jetbrains_file} ]]; then
check_pid
if [[ ! -z "${PID}" ]]; then
echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix}${Green_font_prefix}已启动${Font_color_suffix}"
else
echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix}${Red_font_prefix}未启动${Font_color_suffix}"
fi
else
echo -e " 当前状态: ${Red_font_prefix}未安装${Font_color_suffix}"
fi
echo
read -p " 请输入数字 [1-5]:" num
case "$num" in
1)
Install_jetbrains
;;
2)
Uninstall_jetbrains
;;
3)
Start_jetbrains
;;
4)
Stop_jetbrains
;;
5)
Restart_jetbrains
;;
*)
echo "请输入正确数字 [1-5]"
;;
esac
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ChurchillShingle/adbyby.git
git@gitee.com:ChurchillShingle/adbyby.git
ChurchillShingle
adbyby
adbyby
master

搜索帮助