代码拉取完成,页面将自动刷新
#!/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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。