mirror of
https://github.com/spiritLHLS/one-click-installation-script.git
synced 2024-11-16 12:22:18 +08:00
20230926
This commit is contained in:
parent
965fce6707
commit
e8d430f045
|
@ -131,12 +131,12 @@ sudo sed -i 's/.*precedence ::ffff:0:0\/96.*/precedence ::ffff:0:0\/96 100/g' /
|
|||
- **本脚本尝试使用Miniconda3安装虚拟环境jupyter-env再进行jupyter和jupyterlab的安装,如若安装机器不纯净勿要轻易使用本脚本!**
|
||||
- **本脚本为实验性脚本可能会有各种bug,勿要轻易尝试!**
|
||||
- 验证已支持的系统:
|
||||
- Ubuntu 18/20/22 - 推荐,脚本自动挂起到后台
|
||||
- Debian 9/10/11 - 还行,需要手动挂起到后台,详看脚本运行安装完毕的后续提示
|
||||
- Ubuntu 系 - 推荐,脚本自动挂起到后台
|
||||
- Debian 系 - 部分可能需要手动挂起到后台,详看脚本运行安装完毕的后续提示
|
||||
- 可能支持的系统(未验证):centos 7+,Fedora,Almalinux 8.5+
|
||||
- 执行脚本,之前有用本脚本安装过则直接打印设置的登陆信息,没安装过则进行安装再打印信息,如果已安装但未启动则自动启动后再打印信息
|
||||
- 如果是初次安装无脑输入y回车即可,按照提示进行操作即可,安装完毕将在后台常驻运行,自动添加常用的安装包通道源
|
||||
- 安装完毕后,如果需要在lab中安装第三方库需要在lab中使用terminal并使用conda进行下载而不是pip3下载,这是需要注意的
|
||||
- 安装完毕后,如果需要在lab中安装第三方库需要在lab中使用terminal并使用conda进行下载而不是pip3下载,这是需要注意的一点
|
||||
- 安装过程中有判断是否为中国IP,可选择是否使用中国镜像
|
||||
|
||||
原始用途是方便快捷的在按小时计费的超大型服务器上部署python环境进行科学计算,充分利用时间别浪费在构建环境上。
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2023.04.08
|
||||
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
|
@ -16,27 +15,27 @@ fi
|
|||
ver="2023.04.08"
|
||||
changeLog="一键安装R语言环境"
|
||||
source ~/.bashrc
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
done
|
||||
apt-get --fix-broken install -y > /dev/null 2>&1
|
||||
apt-get --fix-broken install -y >/dev/null 2>&1
|
||||
clear
|
||||
echo "#######################################################################"
|
||||
echo "# ${YELLOW}一键安装R语言环境${PLAIN} #"
|
||||
|
@ -53,29 +52,29 @@ yellow "安装前需使用Miniconda3安装虚拟环境jupyter-env,然后进行
|
|||
yellow "简单的说,需要执行本仓库对应的jupyter安装脚本再运行本脚本安装R语言环境"
|
||||
yellow "如果是初次安装无脑回车即可,按照提示进行操作即可"
|
||||
|
||||
checkupdate(){
|
||||
checkupdate() {
|
||||
yellow "Updating package management sources"
|
||||
${PACKAGE_UPDATE[int]} > /dev/null 2>&1
|
||||
apt-key update > /dev/null 2>&1
|
||||
${PACKAGE_UPDATE[int]} >/dev/null 2>&1
|
||||
apt-key update >/dev/null 2>&1
|
||||
}
|
||||
|
||||
checkroot(){
|
||||
[[ $EUID -ne 0 ]] && echo -e "${RED}请使用 root 用户运行本脚本!${PLAIN}" && exit 1
|
||||
checkroot() {
|
||||
[[ $EUID -ne 0 ]] && echo -e "${RED}请使用 root 用户运行本脚本!${PLAIN}" && exit 1
|
||||
}
|
||||
|
||||
checkR(){
|
||||
checkR() {
|
||||
${PACKAGE_INSTALL[int]} xorg xserver-xorg-dev libx11-dev libxt-dev libcairo2-dev
|
||||
source activate jupyter-env
|
||||
if ! Rscript -e "IRkernel::installspec()" &>/dev/null; then
|
||||
reading "IRkernel is not installed on this system. Do you want to install it? (y/n) " confirminstall
|
||||
echo ""
|
||||
if [ "$confirminstall" != "y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
conda install -c r r-irkernel
|
||||
green "Installed IRkernel package and registered kernel"
|
||||
reading "IRkernel is not installed on this system. Do you want to install it? (y/n) " confirminstall
|
||||
echo ""
|
||||
if [ "$confirminstall" != "y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
conda install -c r r-irkernel
|
||||
green "Installed IRkernel package and registered kernel"
|
||||
else
|
||||
blue "IRkernel is installed"
|
||||
blue "IRkernel is installed"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2022.12.27
|
||||
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
|
@ -14,15 +13,15 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
# Check if C++ is installed
|
||||
if ! type "g++" > /dev/null; then
|
||||
if ! type "g++" >/dev/null; then
|
||||
# Install C++ if it is not installed
|
||||
echo "C++ is not installed. Installing C++..."
|
||||
# Check OS and install C++ using appropriate package manager
|
||||
if type "apt-get" > /dev/null; then
|
||||
if type "apt-get" >/dev/null; then
|
||||
# Ubuntu, Debian
|
||||
sudo apt-get update
|
||||
sudo apt-get install g++
|
||||
elif type "yum" > /dev/null; then
|
||||
elif type "yum" >/dev/null; then
|
||||
# CentOS, Fedora, AlmaLinux
|
||||
sudo yum update
|
||||
sudo yum install gcc-c++
|
||||
|
@ -40,11 +39,11 @@ else
|
|||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Updating C++..."
|
||||
# Check OS and update C++ using appropriate package manager
|
||||
if type "apt-get" > /dev/null; then
|
||||
if type "apt-get" >/dev/null; then
|
||||
# Ubuntu, Debian
|
||||
sudo apt-get update
|
||||
sudo apt-get install g++
|
||||
elif type "yum" > /dev/null; then
|
||||
elif type "yum" >/dev/null; then
|
||||
# CentOS, Fedora, AlmaLinux
|
||||
sudo yum update
|
||||
sudo yum install gcc-c++
|
||||
|
|
|
@ -14,59 +14,59 @@ killall -9 AliYunDun >/dev/null 2>&1
|
|||
killall -9 AliHids >/dev/null 2>&1
|
||||
killall -9 AliHips >/dev/null 2>&1
|
||||
killall -9 AliYunDunUpdate >/dev/null 2>&1
|
||||
if [ -d /usr/local/aegis/aegis_debug ];then
|
||||
if [ -d /usr/local/aegis/aegis_debug/tracing/instances/aegis ];then
|
||||
echo > /usr/local/aegis/aegis_debug/tracing/instances/aegis/set_event
|
||||
if [ -d /usr/local/aegis/aegis_debug ]; then
|
||||
if [ -d /usr/local/aegis/aegis_debug/tracing/instances/aegis ]; then
|
||||
echo >/usr/local/aegis/aegis_debug/tracing/instances/aegis/set_event
|
||||
else
|
||||
echo > /usr/local/aegis/aegis_debug/tracing/set_event
|
||||
echo >/usr/local/aegis/aegis_debug/tracing/set_event
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d /sys/kernel/debug ];then
|
||||
if [ -d /sys/kernel/debug/tracing/instances/aegis ];then
|
||||
echo > /sys/kernel/debug/tracing/instances/aegis/set_event
|
||||
if [ -d /sys/kernel/debug ]; then
|
||||
if [ -d /sys/kernel/debug/tracing/instances/aegis ]; then
|
||||
echo >/sys/kernel/debug/tracing/instances/aegis/set_event
|
||||
else
|
||||
echo > /sys/kernel/debug/tracing/set_event
|
||||
echo >/sys/kernel/debug/tracing/set_event
|
||||
fi
|
||||
fi
|
||||
if [ -d /usr/local/aegis ];then
|
||||
if [ -d /usr/local/aegis ]; then
|
||||
rm -rf /usr/local/aegis/aegis_client
|
||||
rm -rf /usr/local/aegis/aegis_update
|
||||
rm -rf /usr/local/aegis/alihids
|
||||
rm -rf /usr/local/aegis/alihids
|
||||
fi
|
||||
|
||||
if [ -d /usr/local/aegis/aegis_debug ];then
|
||||
if [ -d /usr/local/aegis/aegis_debug ]; then
|
||||
umount /usr/local/aegis/aegis_debug
|
||||
rm -rf /usr/local/aegis/aegis_debug
|
||||
fi
|
||||
if [ -f "/etc/init.d/aegis" ]; then
|
||||
/etc/init.d/aegis stop >/dev/null 2>&1
|
||||
/etc/init.d/aegis stop >/dev/null 2>&1
|
||||
rm -f /etc/init.d/aegis
|
||||
fi
|
||||
|
||||
if [ $LINUX_RELEASE = "GENTOO" ]; then
|
||||
rc-update del aegis default 2>/dev/null
|
||||
if [ -f "/etc/runlevels/default/aegis" ]; then
|
||||
rm -f "/etc/runlevels/default/aegis" >/dev/null 2>&1;
|
||||
rm -f "/etc/runlevels/default/aegis" >/dev/null 2>&1
|
||||
fi
|
||||
elif [ -f /etc/init.d/aegis ]; then
|
||||
/etc/init.d/aegis uninstall
|
||||
for ((var=2; var<=5; var++)) do
|
||||
if [ -d "/etc/rc${var}.d/" ];then
|
||||
rm -f "/etc/rc${var}.d/S80aegis"
|
||||
elif [ -d "/etc/rc.d/rc${var}.d" ];then
|
||||
/etc/init.d/aegis uninstall
|
||||
for ((var = 2; var <= 5; var++)); do
|
||||
if [ -d "/etc/rc${var}.d/" ]; then
|
||||
rm -f "/etc/rc${var}.d/S80aegis"
|
||||
elif [ -d "/etc/rc.d/rc${var}.d" ]; then
|
||||
rm -f "/etc/rc.d/rc${var}.d/S80aegis"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
/usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} stop && \
|
||||
/usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} uninstall && \
|
||||
rm -rf /usr/local/cloudmonitor
|
||||
/usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} stop &&
|
||||
/usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} uninstall &&
|
||||
rm -rf /usr/local/cloudmonitor
|
||||
service aegis stop
|
||||
chkconfig --del aegis
|
||||
/usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh stop
|
||||
/usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh remove && \
|
||||
rm -rf /usr/local/cloudmonitor
|
||||
/usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh remove &&
|
||||
rm -rf /usr/local/cloudmonitor
|
||||
systemctl stop aliyun.service
|
||||
pkill aliyun-service
|
||||
pkill AliYunDun
|
||||
|
@ -95,7 +95,7 @@ systemctl stop --no-block jcs-agent-core
|
|||
systemctl --no-reload disable jcs-agent-core
|
||||
stop --no-wait jcs-agent-core
|
||||
/etc/init.d/jcs-agent-core
|
||||
if [[ -f "/etc/centos-release" && $(grep ' 6' /etc/centos-release) ]];then
|
||||
if [[ -f "/etc/centos-release" && $(grep ' 6' /etc/centos-release) ]]; then
|
||||
echo "Disable expand-root at startup ..."
|
||||
chkconfig --level 2345 expand-root off
|
||||
|
||||
|
|
|
@ -16,29 +16,29 @@ cd /root >/dev/null 2>&1
|
|||
ver="2023.04.18"
|
||||
changeLog="一键安装filebrowser平台"
|
||||
source ~/.bashrc
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
done
|
||||
apt-get --fix-broken install -y > /dev/null 2>&1
|
||||
apt-get --fix-broken install -y >/dev/null 2>&1
|
||||
|
||||
check_ipv4(){
|
||||
check_ipv4() {
|
||||
API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org")
|
||||
for p in "${API_NET[@]}"; do
|
||||
response=$(curl -s4m8 "$p")
|
||||
|
@ -53,42 +53,42 @@ check_ipv4(){
|
|||
}
|
||||
|
||||
checkwget() {
|
||||
if [ ! -e '/usr/bin/wget' ]; then
|
||||
yellow "Installing wget"
|
||||
${PACKAGE_INSTALL[int]} wget
|
||||
fi
|
||||
if [ ! -e '/usr/bin/wget' ]; then
|
||||
yellow "Installing wget"
|
||||
${PACKAGE_INSTALL[int]} wget
|
||||
fi
|
||||
}
|
||||
|
||||
checktar() {
|
||||
yellow "checking tar"
|
||||
if [ ! -e '/usr/bin/tar' ]; then
|
||||
yellow "Installing tar"
|
||||
${PACKAGE_INSTALL[int]} tar
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
apt-get -f install > /dev/null 2>&1
|
||||
${PACKAGE_INSTALL[int]} tar > /dev/null 2>&1
|
||||
fi
|
||||
yellow "checking tar"
|
||||
if [ ! -e '/usr/bin/tar' ]; then
|
||||
yellow "Installing tar"
|
||||
${PACKAGE_INSTALL[int]} tar
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
apt-get -f install >/dev/null 2>&1
|
||||
${PACKAGE_INSTALL[int]} tar >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
build(){
|
||||
build() {
|
||||
cd /root >/dev/null 2>&1
|
||||
local sysarch="$(uname -m)"
|
||||
case "${sysarch}" in
|
||||
"x86_64"|"x86"|"amd64"|"x64") sys_bit="amd64";;
|
||||
"i386"|"i686") sys_bit="386";;
|
||||
"aarch64"|"armv8"|"armv8l") sys_bit="arm64";;
|
||||
"armv5l") sys_bit="armv5";;
|
||||
"armv6l") sys_bit="armv6";;
|
||||
"armv7l") sys_bit="armv7";;
|
||||
*) sys_bit="amd64";;
|
||||
"x86_64" | "x86" | "amd64" | "x64") sys_bit="amd64" ;;
|
||||
"i386" | "i686") sys_bit="386" ;;
|
||||
"aarch64" | "armv8" | "armv8l") sys_bit="arm64" ;;
|
||||
"armv5l") sys_bit="armv5" ;;
|
||||
"armv6l") sys_bit="armv6" ;;
|
||||
"armv7l") sys_bit="armv7" ;;
|
||||
*) sys_bit="amd64" ;;
|
||||
esac
|
||||
wget https://github.com/filebrowser/filebrowser/releases/download/v2.23.0/linux-${sys_bit}-filebrowser.tar.gz
|
||||
tar -xzvf linux-${sys_bit}-filebrowser.tar.gz
|
||||
rm -rf linux-${sys_bit}-filebrowser.tar.gz*
|
||||
}
|
||||
|
||||
run(){
|
||||
run() {
|
||||
nohup ./filebrowser -a 0.0.0.0 -p 3030 >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ build
|
|||
run
|
||||
green "Checking http://$IPV4:3030/ "
|
||||
green "You may login to the dashboard with:"
|
||||
green "Username: admin"
|
||||
green "Username: admin"
|
||||
green "Password: admin"
|
||||
green "Remember to change this password in the manage user page"
|
||||
rm -rf CHANGELOG.md LICENSE README.md
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2023.05.29
|
||||
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
|
@ -14,29 +13,29 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
source ~/.bashrc
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
done
|
||||
apt-get --fix-broken install -y > /dev/null 2>&1
|
||||
apt-get --fix-broken install -y >/dev/null 2>&1
|
||||
|
||||
check_ipv4(){
|
||||
check_ipv4() {
|
||||
API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org")
|
||||
for p in "${API_NET[@]}"; do
|
||||
response=$(curl -s4m8 "$p")
|
||||
|
@ -50,7 +49,6 @@ check_ipv4(){
|
|||
IPV4=$(curl -s4m8 "$IP_API")
|
||||
}
|
||||
|
||||
|
||||
check_ipv4
|
||||
curl -sSL https://get.docker.com/ | sh
|
||||
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
|
@ -59,4 +57,3 @@ docker-compose --version
|
|||
curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/FOSSBilling-compose.yml -o FOSSBilling-compose.yml && chmod +x FOSSBilling-compose.yml
|
||||
docker-compose -f FOSSBilling-compose.yml up
|
||||
echo "Please open http://${IPV4}/install/install.php"
|
||||
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
#by spiritlhl
|
||||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2023.08.07
|
||||
|
||||
#version: 2023.09.26
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
echo "No UTF-8 locale found"
|
||||
else
|
||||
export LC_ALL="$utf8_locale"
|
||||
export LANG="$utf8_locale"
|
||||
export LANGUAGE="$utf8_locale"
|
||||
echo "Locale set to $utf8_locale"
|
||||
export LC_ALL="$utf8_locale"
|
||||
export LANG="$utf8_locale"
|
||||
export LANGUAGE="$utf8_locale"
|
||||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
cd /root >/dev/null 2>&1
|
||||
ver="2023.07.26"
|
||||
changeLog="一键安装jupyter环境"
|
||||
source ~/.bashrc
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
temp_file_apt_fix="apt_fix.txt"
|
||||
REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD")
|
||||
|
@ -28,7 +27,7 @@ PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get
|
|||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed" "pkg install -y")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm" "pkg delete")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "" "pkg autoremove")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(uname -s)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(uname -s)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
|
@ -47,31 +46,31 @@ echo "# ${GREEN}作者${PLAIN}: spiritlhl
|
|||
echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #"
|
||||
echo "#######################################################################"
|
||||
echo "验证已支持的系统:"
|
||||
echo "Ubuntu 18/20/22 - 推荐,脚本自动挂起到后台"
|
||||
echo "Debian 9/10/11 - 还行,需要手动挂起到后台,详看脚本运行安装完毕的后续提示"
|
||||
echo "Ubuntu 系 - 推荐,脚本自动挂起到后台"
|
||||
echo "Debian 系 - 部分可能需要手动挂起到后台,详看脚本运行安装完毕的后续提示"
|
||||
echo "可能支持的系统:centos 7+,Fedora,Almalinux 8.5+"
|
||||
red "本脚本尝试使用Miniconda3安装虚拟环境jupyter-env再进行jupyter和jupyterlab的安装,如若安装机器不纯净勿要轻易使用本脚本!"
|
||||
yellow "执行脚本,之前有用本脚本安装过则直接打印设置的登陆信息,没安装过则进行安装再打印信息,如果已安装但未启动则自动启动后再打印信息"
|
||||
yellow "如果是初次安装无脑y无脑回车即可,按照提示进行操作即可,安装完毕将在后台常驻运行,自动添加常用的安装包通道源"
|
||||
|
||||
check_china(){
|
||||
check_china() {
|
||||
yellow "IP area being detected ......"
|
||||
if [[ -z "${CN}" ]]; then
|
||||
if [[ $(curl -m 6 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||
yellow "根据ipapi.co提供的信息,当前IP可能在中国"
|
||||
read -e -r -p "是否选用中国镜像完成相关组件安装? ([y]/n) " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
*)
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
*)
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
esac
|
||||
else
|
||||
if [[ $? -ne 0 ]]; then
|
||||
|
@ -79,16 +78,16 @@ check_china(){
|
|||
yellow "根据cip.cc提供的信息,当前IP可能在中国"
|
||||
read -e -r -p "是否选用中国镜像完成相关组件安装? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
*)
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
*)
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
@ -96,11 +95,11 @@ check_china(){
|
|||
fi
|
||||
}
|
||||
|
||||
check_update(){
|
||||
check_update() {
|
||||
yellow "Updating package management sources"
|
||||
if command -v apt-get > /dev/null 2>&1; then
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt_update_output=$(apt-get update 2>&1)
|
||||
echo "$apt_update_output" > "$temp_file_apt_fix"
|
||||
echo "$apt_update_output" >"$temp_file_apt_fix"
|
||||
if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then
|
||||
public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }')
|
||||
joined_keys=$(echo "$public_keys" | paste -sd " ")
|
||||
|
@ -120,35 +119,35 @@ check_update(){
|
|||
|
||||
check_sudo() {
|
||||
yellow "checking sudo"
|
||||
if ! command -v sudo > /dev/null 2>&1; then
|
||||
if ! command -v sudo >/dev/null 2>&1; then
|
||||
yellow "Installing sudo"
|
||||
${PACKAGE_INSTALL[int]} sudo > /dev/null 2>&1
|
||||
${PACKAGE_INSTALL[int]} sudo >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
check_wget() {
|
||||
if ! which wget >/dev/null; then
|
||||
if ! which wget >/dev/null; then
|
||||
yellow "Installing wget"
|
||||
${PACKAGE_INSTALL[int]} wget
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_curl() {
|
||||
if ! which curl >/dev/null; then
|
||||
if ! which curl >/dev/null; then
|
||||
yellow "Installing curl"
|
||||
${PACKAGE_INSTALL[int]} curl
|
||||
fi
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
apt-get -f install > /dev/null 2>&1
|
||||
apt-get -f install >/dev/null 2>&1
|
||||
${PACKAGE_INSTALL[int]} curl
|
||||
fi
|
||||
}
|
||||
|
||||
check_ufw() {
|
||||
if ! which ufw >/dev/null; then
|
||||
if ! which ufw >/dev/null; then
|
||||
yellow "Installing ufw"
|
||||
${PACKAGE_INSTALL[int]} ufw
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
is_private_ipv4() {
|
||||
|
@ -157,23 +156,22 @@ is_private_ipv4() {
|
|||
if [[ -z $ip_address ]]; then
|
||||
return 0 # 输入为空
|
||||
fi
|
||||
IFS='.' read -r -a ip_parts <<< "$ip_address"
|
||||
IFS='.' read -r -a ip_parts <<<"$ip_address"
|
||||
# 检查IP地址是否符合内网IP地址的范围
|
||||
# 去除 回环,REC 1918,多播 地址
|
||||
if [[ ${ip_parts[0]} -eq 10 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 172 && ${ip_parts[1]} -ge 16 && ${ip_parts[1]} -le 31 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 192 && ${ip_parts[1]} -eq 168 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 127 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 0 ]] ||
|
||||
[[ ${ip_parts[0]} -ge 224 ]]
|
||||
then
|
||||
return 0 # 是内网IP地址
|
||||
[[ ${ip_parts[0]} -eq 172 && ${ip_parts[1]} -ge 16 && ${ip_parts[1]} -le 31 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 192 && ${ip_parts[1]} -eq 168 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 127 ]] ||
|
||||
[[ ${ip_parts[0]} -eq 0 ]] ||
|
||||
[[ ${ip_parts[0]} -ge 224 ]]; then
|
||||
return 0 # 是内网IP地址
|
||||
else
|
||||
return 1 # 不是内网IP地址
|
||||
return 1 # 不是内网IP地址
|
||||
fi
|
||||
}
|
||||
|
||||
check_ipv4(){
|
||||
check_ipv4() {
|
||||
IPV4=$(ip -4 addr show | grep global | awk '{print $2}' | cut -d '/' -f1 | head -n 1)
|
||||
if is_private_ipv4 "$IPV4"; then # 由于是内网IPV4地址,需要通过API获取外网地址
|
||||
IPV4=""
|
||||
|
@ -192,137 +190,139 @@ check_ipv4(){
|
|||
}
|
||||
|
||||
install_jupyter() {
|
||||
rm -rf Miniconda3-latest-Linux-x86_64.sh*
|
||||
check_update
|
||||
check_sudo
|
||||
check_wget
|
||||
check_curl
|
||||
check_ufw
|
||||
if ! command -v conda &> /dev/null; then
|
||||
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
|
||||
bash Miniconda3-latest-Linux-x86_64.sh -b -u
|
||||
echo 'export PATH="$PATH:$HOME/miniconda3/bin:$HOME/miniconda3/condabin"' >> ~/.bashrc
|
||||
echo 'export PATH="$PATH:$HOME/.local/share/jupyter"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
rm -rf Miniconda3-latest-Linux-x86_64.sh*
|
||||
check_update
|
||||
check_sudo
|
||||
check_wget
|
||||
check_curl
|
||||
check_ufw
|
||||
if ! command -v conda &>/dev/null; then
|
||||
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
|
||||
bash Miniconda3-latest-Linux-x86_64.sh -b -u
|
||||
echo 'export PATH="$PATH:$HOME/miniconda3/bin:$HOME/miniconda3/condabin"' >>~/.bashrc
|
||||
echo 'export PATH="$PATH:$HOME/.local/share/jupyter"' >>~/.bashrc
|
||||
source ~/.bashrc
|
||||
sleep 1
|
||||
echo 'export PATH="/home/user/miniconda3/bin:$PATH"' >>~/.bashrc
|
||||
source ~/.bashrc
|
||||
sleep 1
|
||||
export PATH="/home/user/miniconda3/bin:$PATH"
|
||||
green "请关闭本窗口开一个新窗口再执行本脚本,否则无法加载一些预设的环境变量(或断开SSH连接后重新连接)" && exit 0
|
||||
fi
|
||||
green "加载预设的conda环境变量成功,准备安装jupyter,无脑输入y和回车即可"
|
||||
conda create -n jupyter-env python=3
|
||||
sleep 5
|
||||
source activate jupyter-env
|
||||
sleep 1
|
||||
echo 'export PATH="/home/user/miniconda3/bin:$PATH"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
sleep 1
|
||||
export PATH="/home/user/miniconda3/bin:$PATH"
|
||||
green "请关闭本窗口开一个新窗口再执行本脚本,否则无法加载一些预设的环境变量(或断开SSH连接后重新连接)" && exit 0
|
||||
fi
|
||||
green "加载预设的conda环境变量成功,准备安装jupyter,无脑输入y和回车即可"
|
||||
conda create -n jupyter-env python=3
|
||||
sleep 5
|
||||
source activate jupyter-env
|
||||
sleep 1
|
||||
conda install jupyter jupyterlab
|
||||
check_china
|
||||
if [[ -n "${CN}" && "${CN}" == true ]]; then
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
conda config --set show_channel_urls yes
|
||||
fi
|
||||
echo 'export PATH="$PATH:~/.local/share/jupyter"' >> /etc/profile
|
||||
source /etc/profile
|
||||
# jupyter notebook --generate-config
|
||||
# cp ~/.jupyter/jupyter_notebook_config.py ~/.jupyter/jupyter_server_config.py
|
||||
jupyter server --generate-config
|
||||
# echo "c.ServerApp.password = 'spiritlhl'" >> ~/.jupyter/jupyter_server_config.py
|
||||
# echo "c.ServerApp.username = 'spiritlhl'" >> ~/.jupyter/jupyter_server_config.py
|
||||
if command -v ufw &> /dev/null; then
|
||||
sudo ufw allow 13692/tcp
|
||||
elif command -v firewall-cmd &> /dev/null; then
|
||||
sudo firewall-cmd --add-port=13692/tcp --permanent
|
||||
sudo firewall-cmd --reload
|
||||
fi
|
||||
ubuntu_version=$(lsb_release -rs)
|
||||
channels_to_add=(
|
||||
"dglteam"
|
||||
"pytorch"
|
||||
"conda-forge"
|
||||
"anaconda"
|
||||
)
|
||||
if [ "$ubuntu_version" == "18.04" ] || [ "$ubuntu_version" == "20.04" ] || [ "$ubuntu_version" == "22.04" ]; then
|
||||
conda install jupyter jupyterlab
|
||||
check_china
|
||||
if [[ -n "${CN}" && "${CN}" == true ]]; then
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
conda config --set show_channel_urls yes
|
||||
fi
|
||||
echo 'export PATH="$PATH:~/.local/share/jupyter"' >>/etc/profile
|
||||
source /etc/profile
|
||||
# jupyter notebook --generate-config
|
||||
# cp ~/.jupyter/jupyter_notebook_config.py ~/.jupyter/jupyter_server_config.py
|
||||
jupyter server --generate-config
|
||||
# echo "c.ServerApp.password = 'spiritlhl'" >> ~/.jupyter/jupyter_server_config.py
|
||||
# echo "c.ServerApp.username = 'spiritlhl'" >> ~/.jupyter/jupyter_server_config.py
|
||||
if command -v ufw &>/dev/null; then
|
||||
sudo ufw allow 13692/tcp
|
||||
elif command -v firewall-cmd &>/dev/null; then
|
||||
sudo firewall-cmd --add-port=13692/tcp --permanent
|
||||
sudo firewall-cmd --reload
|
||||
fi
|
||||
ubuntu_version=$(lsb_release -rs)
|
||||
channels_to_add=(
|
||||
"dglteam"
|
||||
"pytorch"
|
||||
"conda-forge"
|
||||
"anaconda"
|
||||
)
|
||||
|
||||
source activate jupyter-env
|
||||
sleep 1
|
||||
rm -rf nohup.out
|
||||
green "后台执行的pid的进程ID和输出日志文件名字如下"
|
||||
nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root & green $!
|
||||
nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root &
|
||||
green $!
|
||||
sleep 5
|
||||
cat nohup.out
|
||||
else
|
||||
echo "你正在除了Ubuntu系统之外的系统执行,运行的最后几行可能有如下提示"
|
||||
yellow "nohup: failed to run command 'jupyter': No such file or directory"
|
||||
echo "非Ubuntu的系统你需要手动执行下面的命令"
|
||||
yellow "source activate jupyter-env"
|
||||
yellow "nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root"
|
||||
green "等待5秒后关闭本窗口,开新窗口执行下面的命令查看登陆信息"
|
||||
yellow "cat nohup.out"
|
||||
echo "非Ubuntu系统只有上面这样才能手动挂起jupyter后台执行"
|
||||
fi
|
||||
current_channels=$(conda config --get channels)
|
||||
for channel in "${channels_to_add[@]}"; do
|
||||
if echo "$current_channels" | grep -q "$channel" >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
conda config --add channels "$channel" >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
paths="./miniconda3/envs/jupyter-env/etc/jupyter:./miniconda3/envs/jupyter-env/bin/jupyter:./miniconda3/envs/jupyter-env/share/jupyter"
|
||||
export PATH="$paths:$PATH"
|
||||
new_path=$(echo "$PATH" | tr ':' '\n' | awk '!x[$0]++' | tr '\n' ':')
|
||||
export PATH="$new_path"
|
||||
source ~/.bashrc
|
||||
check_ipv4
|
||||
jpyurl="http://${IPV4}:13692/"
|
||||
green "已安装jupyter lab的web端到外网端口13692上,请打开你的 外网IP:13692"
|
||||
green "如果你是在云服务上运行,那么请打开 ${jpyurl} 如果是在本地安装的,请打开 http://127.0.0.1:13692/"
|
||||
green "初次安装会要求输入token设置密码,token详见上方打印信息或当前目录的nohup.out日志"
|
||||
green "同时已保存日志输出到当前目录的nohup.out中且已打印5秒日志如上"
|
||||
green "如果需要进一步查询,请关闭本窗口开一个新窗口再执行本脚本,否则无法加载一些预设的环境变量"
|
||||
green "如果想要手动查询,输入 source activate jupyter-env && jupyter server list && conda deactivate 即可查询"
|
||||
exit 0
|
||||
if grep -q 'token=' nohup.out >/dev/null 2>&1; then
|
||||
cat nohup.out
|
||||
else
|
||||
echo "你可能在不支持的系统是执行,运行的最后几行可能有如下提示"
|
||||
yellow "nohup: failed to run command 'jupyter': No such file or directory"
|
||||
echo "你需要手动执行下面的命令"
|
||||
yellow "source activate jupyter-env"
|
||||
yellow "nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root"
|
||||
green "等待5秒后关闭本窗口,开新窗口执行下面的命令查看登陆信息"
|
||||
yellow "cat nohup.out"
|
||||
echo "如若无成功输出,可尝试重新运行本脚本"
|
||||
fi
|
||||
current_channels=$(conda config --get channels)
|
||||
for channel in "${channels_to_add[@]}"; do
|
||||
if echo "$current_channels" | grep -q "$channel" >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
conda config --add channels "$channel" >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
paths="./miniconda3/envs/jupyter-env/etc/jupyter:./miniconda3/envs/jupyter-env/bin/jupyter:./miniconda3/envs/jupyter-env/share/jupyter"
|
||||
export PATH="$paths:$PATH"
|
||||
new_path=$(echo "$PATH" | tr ':' '\n' | awk '!x[$0]++' | tr '\n' ':')
|
||||
export PATH="$new_path"
|
||||
source ~/.bashrc
|
||||
check_ipv4
|
||||
jpyurl="http://${IPV4}:13692/"
|
||||
green "已安装jupyter lab的web端到外网端口13692上,请打开你的 外网IP:13692"
|
||||
green "如果你是在云服务上运行,那么请打开 ${jpyurl} 如果是在本地安装的,请打开 http://127.0.0.1:13692/"
|
||||
green "初次安装会要求输入token设置密码,token详见上方打印信息或当前目录的nohup.out日志"
|
||||
green "同时已保存日志输出到当前目录的nohup.out中且已打印5秒日志如上"
|
||||
green "如果需要进一步查询,请关闭本窗口开一个新窗口再执行本脚本,否则无法加载一些预设的环境变量"
|
||||
green "如果想要手动查询,输入 source activate jupyter-env && jupyter server list && conda deactivate 即可查询"
|
||||
exit 0
|
||||
}
|
||||
|
||||
query_jupyter_info() {
|
||||
source activate jupyter-env > /dev/null 2>&1
|
||||
if ! jupyter --version &> /dev/null; then
|
||||
echo "Error: Jupyter is not installed on this system."
|
||||
return 1
|
||||
fi
|
||||
check_ipv4
|
||||
jpyurl="http://${IPV4}:13692/"
|
||||
source activate jupyter-env && jupyter server list && conda deactivate
|
||||
cat nohup.out
|
||||
green "已查询登陆信息如上"
|
||||
green "如果你是在云服务上运行,那么请打开 ${jpyurl} 如果是在本地安装的,请打开 http://127.0.0.1:13692/"
|
||||
green "token详见上方打印信息或当前目录的nohup.out日志"
|
||||
green "如果想要手动查询,输入 source activate jupyter-env && jupyter server list && conda deactivate 即可查询"
|
||||
source activate jupyter-env >/dev/null 2>&1
|
||||
if ! jupyter --version &>/dev/null; then
|
||||
echo "Error: Jupyter is not installed on this system."
|
||||
return 1
|
||||
fi
|
||||
check_ipv4
|
||||
jpyurl="http://${IPV4}:13692/"
|
||||
source activate jupyter-env && jupyter server list && conda deactivate
|
||||
cat nohup.out
|
||||
green "已查询登陆信息如上"
|
||||
green "如果你是在云服务上运行,那么请打开 ${jpyurl} 如果是在本地安装的,请打开 http://127.0.0.1:13692/"
|
||||
green "token详见上方打印信息或当前目录的nohup.out日志"
|
||||
green "如果想要手动查询,输入 source activate jupyter-env && jupyter server list && conda deactivate 即可查询"
|
||||
}
|
||||
|
||||
main() {
|
||||
source activate jupyter-env > /dev/null 2>&1
|
||||
if jupyter --version &> /dev/null; then
|
||||
green "Jupyter is already installed on this system."
|
||||
if ! (nc -z localhost 13692) > /dev/null 2>&1
|
||||
then
|
||||
source activate jupyter-env
|
||||
rm -rf nohup.out
|
||||
green "后台未启动jupyter,正在启动"
|
||||
nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root & green $!
|
||||
sleep 1
|
||||
jupyter lab
|
||||
source activate jupyter-env >/dev/null 2>&1
|
||||
if jupyter --version &>/dev/null; then
|
||||
green "Jupyter is already installed on this system."
|
||||
if ! (nc -z localhost 13692) >/dev/null 2>&1; then
|
||||
source activate jupyter-env
|
||||
rm -rf nohup.out
|
||||
green "后台未启动jupyter,正在启动"
|
||||
nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root &
|
||||
green $!
|
||||
sleep 1
|
||||
jupyter lab
|
||||
fi
|
||||
else
|
||||
reading "Jupyter is not installed on this system. Do you want to install it? (y/n) " confirminstall
|
||||
echo ""
|
||||
if [ "$confirminstall" != "y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
install_jupyter
|
||||
fi
|
||||
else
|
||||
reading "Jupyter is not installed on this system. Do you want to install it? (y/n) " confirminstall
|
||||
echo ""
|
||||
if [ "$confirminstall" != "y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
install_jupyter
|
||||
fi
|
||||
green "The current info for Jupyter:"
|
||||
query_jupyter_info
|
||||
green "The current info for Jupyter:"
|
||||
query_jupyter_info
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2022.12.17
|
||||
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
|
@ -13,11 +12,10 @@ else
|
|||
export LANGUAGE="$utf8_locale"
|
||||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
# 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+
|
||||
ver="2022.12.18"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2023.02.25
|
||||
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
|
@ -22,8 +21,8 @@ _blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
|||
|
||||
# 检查是否为 root 用户
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
_red "请使用 root 用户执行脚本"
|
||||
exit 1
|
||||
_red "请使用 root 用户执行脚本"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 判断是否为 Debian 系统
|
||||
|
@ -78,7 +77,7 @@ elif [ $CURRENT_VERSION == "buster" ]; then
|
|||
sed -i 's/buster/bullseye/g' /etc/apt/sources.list
|
||||
fi
|
||||
|
||||
replace(){
|
||||
replace() {
|
||||
sed -i 's/^deb http:\/\/security.debian.org\/debian-security wheezy\/updates main/# &/' /etc/apt/sources.list
|
||||
sed -i 's/^deb-src http:\/\/security.debian.org\/debian-security wheezy\/updates main/# &/' /etc/apt/sources.list
|
||||
sed -i 's/^deb http:\/\/security.debian.org\/debian-security jessie\/updates main/# &/' /etc/apt/sources.list
|
||||
|
@ -93,9 +92,9 @@ replace(){
|
|||
|
||||
apt-get update
|
||||
if [ $? -ne 0 ]; then
|
||||
# 去除漏洞修补源避免更新异常
|
||||
replace > /dev/null 2>&1
|
||||
apt-get update
|
||||
# 去除漏洞修补源避免更新异常
|
||||
replace >/dev/null 2>&1
|
||||
apt-get update
|
||||
fi
|
||||
apt-get upgrade -y
|
||||
apt-get full-upgrade -y
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
|
||||
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
echo "No UTF-8 locale found"
|
||||
|
@ -17,7 +16,7 @@ _red() { echo -e "\033[31m\033[01m$@\033[0m"; }
|
|||
_green() { echo -e "\033[32m\033[01m$@\033[0m"; }
|
||||
_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; }
|
||||
_blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||
reading(){ read -rp "$(_green "$1")" "$2"; }
|
||||
reading() { read -rp "$(_green "$1")" "$2"; }
|
||||
|
||||
# 检查是否有sudo权限
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
|
@ -69,4 +68,3 @@ else
|
|||
_green "Upgrading Ubuntu 20/21 to 22..."
|
||||
do-release-upgrade -d -f DistUpgradeViewNonInteractive
|
||||
fi
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ else
|
|||
export LANGUAGE="$utf8_locale"
|
||||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
head() {
|
||||
ver="2023.02.15"
|
||||
|
@ -40,22 +40,21 @@ head() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
check_os() {
|
||||
# 检测系统类型
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
# Ubuntu/Debian/Almalinux
|
||||
OS="Ubuntu/Debian/Almalinux"
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
# CentOS/Fedora
|
||||
OS="CentOS/Fedora"
|
||||
else
|
||||
# 未知系统
|
||||
OS="Unknown"
|
||||
fi
|
||||
# 检测系统类型
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
# Ubuntu/Debian/Almalinux
|
||||
OS="Ubuntu/Debian/Almalinux"
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
# CentOS/Fedora
|
||||
OS="CentOS/Fedora"
|
||||
else
|
||||
# 未知系统
|
||||
OS="Unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
main(){
|
||||
main() {
|
||||
if [ "$OS" == "Ubuntu/Debian/Almalinux" ]; then
|
||||
# Update package repositories and install dependencies
|
||||
apt-get update
|
||||
|
@ -74,15 +73,15 @@ main(){
|
|||
# Enable and start the vnstat service
|
||||
systemctl enable vnstat
|
||||
systemctl start vnstat
|
||||
|
||||
|
||||
apt-get install chkconfig -y
|
||||
if [ $? -ne 0 ]; then
|
||||
apt-get install sysv-rc-conf -y
|
||||
if [ $? -ne 0 ]; then
|
||||
apt-get update && apt-get install sysv-rc-conf -y
|
||||
fi
|
||||
apt-get install sysv-rc-conf -y
|
||||
if [ $? -ne 0 ]; then
|
||||
apt-get update && apt-get install sysv-rc-conf -y
|
||||
fi
|
||||
fi
|
||||
! chkconfig vnstat on && echo "replace chkconfig with sysv-rc-conf" && sysv-rc-conf vnstat on
|
||||
! chkconfig vnstat on && echo "replace chkconfig with sysv-rc-conf" && sysv-rc-conf vnstat on
|
||||
service vnstat start
|
||||
|
||||
# Check if vnstat is installed and working properly
|
||||
|
@ -91,9 +90,9 @@ main(){
|
|||
|
||||
# Check if vnstati is installed and working properly
|
||||
if which vnstati >/dev/null; then
|
||||
vnstati -v
|
||||
vnstati -v
|
||||
else
|
||||
echo "vnstat was compiled and installed without the vnstati tool. If you need to use it, please run 'apt-get install vnstati -y' to install the version from the package repository."
|
||||
echo "vnstat was compiled and installed without the vnstati tool. If you need to use it, please run 'apt-get install vnstati -y' to install the version from the package repository."
|
||||
fi
|
||||
elif [ "$OS" == "CentOS/Fedora" ]; then
|
||||
yum update -y
|
||||
|
@ -119,9 +118,9 @@ main(){
|
|||
|
||||
# Check if vnstati is installed and working properly
|
||||
if which vnstati >/dev/null; then
|
||||
vnstati -v
|
||||
vnstati -v
|
||||
else
|
||||
echo "vnstat was compiled and installed without the vnstati tool. If you need to use it, please run 'yum install vnstati -y' or 'dnf install vnstati -y' to install the version from the package repository."
|
||||
echo "vnstat was compiled and installed without the vnstati tool. If you need to use it, please run 'yum install vnstati -y' or 'dnf install vnstati -y' to install the version from the package repository."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -16,27 +16,27 @@ cd /root >/dev/null 2>&1
|
|||
ver="2023.06.05"
|
||||
changeLog="一键安装Zipline平台"
|
||||
source ~/.bashrc
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
done
|
||||
apt-get --fix-broken install -y > /dev/null 2>&1
|
||||
apt-get --fix-broken install -y >/dev/null 2>&1
|
||||
clear
|
||||
echo "#######################################################################"
|
||||
echo "# ${YELLOW}一键安装Zipline平台${PLAIN} #"
|
||||
|
@ -47,7 +47,7 @@ echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installa
|
|||
echo "#######################################################################"
|
||||
|
||||
# 判断宿主机的 IPv4 或双栈情况 没有拉取不了 docker
|
||||
check_ipv4(){
|
||||
check_ipv4() {
|
||||
# 遍历本机可以使用的 IP API 服务商
|
||||
# 定义可能的 IP API 服务商
|
||||
API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org")
|
||||
|
@ -70,35 +70,35 @@ check_ipv4(){
|
|||
IPV4=$(curl -s4m8 "$IP_API")
|
||||
}
|
||||
|
||||
build(){
|
||||
build() {
|
||||
if ! systemctl is-active docker >/dev/null 2>&1; then
|
||||
green "\n Install docker.\n "
|
||||
if [ $SYSTEM = "CentOS" ]; then
|
||||
${PACKAGE_INSTALL[int]} yum-utils
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &&
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
systemctl enable --now docker
|
||||
else
|
||||
${PACKAGE_INSTALL[int]} docker.io
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
green "\n Install Docker Compose \n"
|
||||
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
green "\n Install Docker Compose \n"
|
||||
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
if [ ! -d "zipline" ] && ! docker ps -a | awk '{print $NF}' | grep -q -E 'postgres|zipline'; then
|
||||
green "\n Building \n "
|
||||
git clone https://github.com/diced/zipline
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
green "\n Install git.\n "
|
||||
if [ $SYSTEM = "CentOS" ]; then
|
||||
${PACKAGE_INSTALL[int]} git
|
||||
else
|
||||
${PACKAGE_INSTALL[int]} git-core
|
||||
fi
|
||||
green "\n Install git.\n "
|
||||
if [ $SYSTEM = "CentOS" ]; then
|
||||
${PACKAGE_INSTALL[int]} git
|
||||
else
|
||||
${PACKAGE_INSTALL[int]} git-core
|
||||
fi
|
||||
fi
|
||||
cd /root/zipline
|
||||
docker-compose up -d
|
||||
|
@ -112,33 +112,32 @@ build(){
|
|||
docker-compose pull
|
||||
docker-compose up -d
|
||||
fi
|
||||
|
||||
|
||||
green "Checking http://$IPV4:3000/ "
|
||||
green "You may login to the dashboard with:"
|
||||
green "Username: administrator"
|
||||
green "Username: administrator"
|
||||
green "Password: password"
|
||||
green "Remember to change this password in the manage user page"
|
||||
}
|
||||
|
||||
check_nginx(){
|
||||
if ! [ -x "$(command -v nginx)" ]; then
|
||||
green "\n Install nginx.\n "
|
||||
${PACKAGE_UPDATE[int]}
|
||||
${PACKAGE_INSTALL[int]} nginx
|
||||
fi
|
||||
check_nginx() {
|
||||
if ! [ -x "$(command -v nginx)" ]; then
|
||||
green "\n Install nginx.\n "
|
||||
${PACKAGE_UPDATE[int]}
|
||||
${PACKAGE_INSTALL[int]} nginx
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
build_reverse_proxy() {
|
||||
green "\n Build reverse proxy. \n "
|
||||
reading "Enter the domain name to bind to (format: www.example.com): " domain_name
|
||||
resolved_ip=$(dig +short $domain_name)
|
||||
if [ "$resolved_ip" != "$IPV4" ]; then
|
||||
red "Error: $domain_name is not bound to the local IP address."
|
||||
exit 1
|
||||
fi
|
||||
green "\n Build reverse proxy. \n "
|
||||
reading "Enter the domain name to bind to (format: www.example.com): " domain_name
|
||||
resolved_ip=$(dig +short $domain_name)
|
||||
if [ "$resolved_ip" != "$IPV4" ]; then
|
||||
red "Error: $domain_name is not bound to the local IP address."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo tee /etc/nginx/sites-available/reverse-proxy <<EOF
|
||||
sudo tee /etc/nginx/sites-available/reverse-proxy <<EOF
|
||||
server {
|
||||
listen 80;
|
||||
client_max_body_size 100M;
|
||||
|
@ -153,25 +152,24 @@ server {
|
|||
}
|
||||
EOF
|
||||
|
||||
sudo ln -s /etc/nginx/sites-available/reverse-proxy /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
if [ $? -ne 0 ]; then
|
||||
red "Error: There is an error in the reverse proxy configuration file. Please check:"
|
||||
yellow "https://zipline.diced.tech/docs/guides/nginx/nginx-no-ssl"
|
||||
exit 1
|
||||
fi
|
||||
sudo systemctl restart nginx
|
||||
green "Because nginx set the reverse proxy to bind the $domain_name, remember to set your domain name in the panel backend to enable it."
|
||||
green "Fill in the options for Domains at http://$domain_name"
|
||||
sudo ln -s /etc/nginx/sites-available/reverse-proxy /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
if [ $? -ne 0 ]; then
|
||||
red "Error: There is an error in the reverse proxy configuration file. Please check:"
|
||||
yellow "https://zipline.diced.tech/docs/guides/nginx/nginx-no-ssl"
|
||||
exit 1
|
||||
fi
|
||||
sudo systemctl restart nginx
|
||||
green "Because nginx set the reverse proxy to bind the $domain_name, remember to set your domain name in the panel backend to enable it."
|
||||
green "Fill in the options for Domains at http://$domain_name"
|
||||
}
|
||||
|
||||
|
||||
check_ipv4
|
||||
build
|
||||
reading "Do you want to set up a reverse proxy for a domain name? (y/n): " answer
|
||||
if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then
|
||||
green "Exiting the script."
|
||||
exit 0
|
||||
green "Exiting the script."
|
||||
exit 0
|
||||
fi
|
||||
check_nginx
|
||||
build_reverse_proxy
|
||||
|
|
|
@ -12,10 +12,10 @@ else
|
|||
export LANGUAGE="$utf8_locale"
|
||||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
head() {
|
||||
# 支持系统:Ubuntu 12+,Debian 6+
|
||||
|
@ -59,7 +59,7 @@ else
|
|||
backup_file="/etc/hosts-$(date +%Y%m%d%H%M%S).bak"
|
||||
cp /etc/hosts "$backup_file"
|
||||
yellow "Backed up /etc/hosts to $backup_file"
|
||||
awk -v new_ip="127.0.0.1" -v hostname="$HOSTNAME" '{ if ($2 == hostname) { print new_ip " " $2 } else { print $0 } }' /etc/hosts > "$temp_file"
|
||||
awk -v new_ip="127.0.0.1" -v hostname="$HOSTNAME" '{ if ($2 == hostname) { print new_ip " " $2 } else { print $0 } }' /etc/hosts >"$temp_file"
|
||||
cp "$temp_file" /etc/hosts
|
||||
rm "$temp_file"
|
||||
else
|
||||
|
@ -68,7 +68,6 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Check if the sudo command works
|
||||
sudo yellow "Testing sudo command..."
|
||||
if [ $? -eq 0 ]; then
|
||||
|
|
|
@ -3,24 +3,24 @@
|
|||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||||
#version: 2023.05.22
|
||||
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
done
|
||||
utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8")
|
||||
if [[ -z "$utf8_locale" ]]; then
|
||||
|
@ -31,8 +31,8 @@ else
|
|||
export LANGUAGE="$utf8_locale"
|
||||
green "Locale set to $utf8_locale"
|
||||
fi
|
||||
apt-get --fix-broken install -y > /dev/null 2>&1
|
||||
rm -rf test_result.txt > /dev/null 2>&1
|
||||
apt-get --fix-broken install -y >/dev/null 2>&1
|
||||
rm -rf test_result.txt >/dev/null 2>&1
|
||||
|
||||
head() {
|
||||
ver="2023.05.22"
|
||||
|
@ -57,15 +57,15 @@ head() {
|
|||
fi
|
||||
}
|
||||
|
||||
check_time_zone(){
|
||||
_yellow "adjusting the time"
|
||||
if ! command -v chronyd > /dev/null 2>&1; then
|
||||
${PACKAGE_INSTALL[int]} chrony > /dev/null 2>&1
|
||||
fi
|
||||
systemctl stop chronyd
|
||||
chronyd -q
|
||||
systemctl start chronyd
|
||||
sleep 0.5
|
||||
check_time_zone() {
|
||||
_yellow "adjusting the time"
|
||||
if ! command -v chronyd >/dev/null 2>&1; then
|
||||
${PACKAGE_INSTALL[int]} chrony >/dev/null 2>&1
|
||||
fi
|
||||
systemctl stop chronyd
|
||||
chronyd -q
|
||||
systemctl start chronyd
|
||||
sleep 0.5
|
||||
}
|
||||
|
||||
head
|
||||
|
|
|
@ -13,10 +13,10 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
head() {
|
||||
# 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+
|
||||
|
@ -47,11 +47,11 @@ main() {
|
|||
external_ip=$(host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}')
|
||||
# 判断 IP 类型并执行对应的函数
|
||||
if [[ $external_ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
main_v4
|
||||
main_v4
|
||||
elif [[ $external_ip =~ ^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$ ]]; then
|
||||
main_v6
|
||||
main_v6
|
||||
else
|
||||
echo "无法识别外网 IP 地址类型"
|
||||
echo "无法识别外网 IP 地址类型"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -70,17 +70,17 @@ main_v4() {
|
|||
fi
|
||||
|
||||
# Try using Google's nameserver
|
||||
echo "nameserver 8.8.8.8" > /etc/resolv.conf
|
||||
echo "nameserver 8.8.8.8" >/etc/resolv.conf
|
||||
if ping -c 1 google.com; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Try using Cloudflare's nameserver
|
||||
echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||
echo "nameserver 1.1.1.1" >/etc/resolv.conf
|
||||
if ping -c 1 google.com; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
# Display prompt asking whether to proceed with checking and changing priority
|
||||
reading "Do you want to proceed with checking and changing network priority? [y/n] " priority
|
||||
echo ""
|
||||
|
@ -105,9 +105,9 @@ main_v4() {
|
|||
|
||||
# Modify network priority if necessary
|
||||
if [ "$ip_type" = "IPv4" ] && [ "$priority" -gt "100" ]; then
|
||||
echo "precedence ::ffff:0:0/96 50" > /etc/gai.conf
|
||||
echo "precedence ::ffff:0:0/96 50" >/etc/gai.conf
|
||||
elif [ "$ip_type" = "IPv6" ] && [ "$priority" -lt "100" ]; then
|
||||
echo "precedence ::/0 100" > /etc/gai.conf
|
||||
echo "precedence ::/0 100" >/etc/gai.conf
|
||||
fi
|
||||
|
||||
# Check if ping to google.com is successful after modifying network priority
|
||||
|
@ -124,55 +124,54 @@ main_v4() {
|
|||
}
|
||||
|
||||
main_v6() {
|
||||
# 定义 nameserver 列表
|
||||
nameservers=(
|
||||
"2001:67c:2960:5353:5353:5353:5353:5353"
|
||||
"2001:67c:2960:6464:6464:6464:6464:6464"
|
||||
"2602:fc23:18::7"
|
||||
"2001:67c:27e4::60"
|
||||
"2001:67c:27e4:15::64"
|
||||
"2001:67c:27e4::64"
|
||||
"2001:67c:27e4:15::6411"
|
||||
"2a01:4f9:c010:3f02::1"
|
||||
"2a00:1098:2c::1"
|
||||
"2a00:1098:2b::1"
|
||||
"2a01:4f8:c2c:123f::1"
|
||||
"2001:67c:2960::64"
|
||||
"2001:67c:2960::6464"
|
||||
"2001:67c:2960::64"
|
||||
"2001:67c:2960::6464"
|
||||
"2001:67c:2b0::6"
|
||||
"2001:67c:2b0::4"
|
||||
"2a03:7900:2:0:31:3:104:161"
|
||||
)
|
||||
# 定义 nameserver 列表
|
||||
nameservers=(
|
||||
"2001:67c:2960:5353:5353:5353:5353:5353"
|
||||
"2001:67c:2960:6464:6464:6464:6464:6464"
|
||||
"2602:fc23:18::7"
|
||||
"2001:67c:27e4::60"
|
||||
"2001:67c:27e4:15::64"
|
||||
"2001:67c:27e4::64"
|
||||
"2001:67c:27e4:15::6411"
|
||||
"2a01:4f9:c010:3f02::1"
|
||||
"2a00:1098:2c::1"
|
||||
"2a00:1098:2b::1"
|
||||
"2a01:4f8:c2c:123f::1"
|
||||
"2001:67c:2960::64"
|
||||
"2001:67c:2960::6464"
|
||||
"2001:67c:2960::64"
|
||||
"2001:67c:2960::6464"
|
||||
"2001:67c:2b0::6"
|
||||
"2001:67c:2b0::4"
|
||||
"2a03:7900:2:0:31:3:104:161"
|
||||
)
|
||||
|
||||
# 保存当前 nameserver 的值,以便之后恢复
|
||||
current_nameserver=$(cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}')
|
||||
# 保存当前 nameserver 的值,以便之后恢复
|
||||
current_nameserver=$(cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}')
|
||||
|
||||
# 循环尝试替换 nameserver 并测试网络
|
||||
for nameserver in "${nameservers[@]}"; do
|
||||
# 替换 nameserver
|
||||
echo "nameserver $nameserver" > /etc/resolv.conf
|
||||
# 循环尝试替换 nameserver 并测试网络
|
||||
for nameserver in "${nameservers[@]}"; do
|
||||
# 替换 nameserver
|
||||
echo "nameserver $nameserver" >/etc/resolv.conf
|
||||
|
||||
# 让修改生效
|
||||
resolvconf -u
|
||||
|
||||
# ping 测试
|
||||
if ping -c 3 google.com &> /dev/null && ping -c 3 github.com &> /dev/null; then
|
||||
green "网络恢复成功"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
# 如果所有 nameserver 都尝试过了仍然无法修复,则恢复为原来的 nameserver
|
||||
echo "nameserver $current_nameserver" > /etc/resolv.conf
|
||||
# 让修改生效
|
||||
resolvconf -u
|
||||
}
|
||||
|
||||
# ping 测试
|
||||
if ping -c 3 google.com &>/dev/null && ping -c 3 github.com &>/dev/null; then
|
||||
green "网络恢复成功"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
# 如果所有 nameserver 都尝试过了仍然无法修复,则恢复为原来的 nameserver
|
||||
echo "nameserver $current_nameserver" >/etc/resolv.conf
|
||||
resolvconf -u
|
||||
}
|
||||
|
||||
head
|
||||
main
|
||||
# ping 测试
|
||||
if ping -c 3 google.com &> /dev/null && ping -c 3 github.com &> /dev/null; then
|
||||
green "V4网络恢复成功"
|
||||
if ping -c 3 google.com &>/dev/null && ping -c 3 github.com &>/dev/null; then
|
||||
green "V4网络恢复成功"
|
||||
fi
|
||||
|
|
|
@ -13,10 +13,10 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
temp_file_apt_fix="/tmp/apt_fix.txt"
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
head() {
|
||||
# 支持系统:Ubuntu 12+,Debian 6+
|
||||
|
@ -51,11 +51,11 @@ head() {
|
|||
backup_source() {
|
||||
# Backup current sources list
|
||||
if test -f /etc/apt/sources.list.bak; then
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list2.bak
|
||||
yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list2.bak"
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list2.bak
|
||||
yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list2.bak"
|
||||
else
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list.bak"
|
||||
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list.bak"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -63,11 +63,11 @@ change_debian_apt_sources() {
|
|||
# Check if the IP is in China
|
||||
ip=$(curl -s https://ipapi.co/ip)
|
||||
location=$(curl -s https://ipapi.co/$ip/country_name)
|
||||
|
||||
|
||||
# Backup current sources list
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list.bak"
|
||||
|
||||
|
||||
# Determine Debian version
|
||||
DEBIAN_VERSION=$(lsb_release -sr)
|
||||
|
||||
|
@ -81,18 +81,18 @@ change_debian_apt_sources() {
|
|||
|
||||
# Set Debian release based on Debian version
|
||||
case $DEBIAN_VERSION in
|
||||
6*) DEBIAN_RELEASE="squeeze";;
|
||||
7*) DEBIAN_RELEASE="wheezy";;
|
||||
8*) DEBIAN_RELEASE="jessie";;
|
||||
9*) DEBIAN_RELEASE="stretch";;
|
||||
10*) DEBIAN_RELEASE="buster";;
|
||||
11*) DEBIAN_RELEASE="bullseye";;
|
||||
12*) DEBIAN_RELEASE="bookworm";;
|
||||
*) echo "The system is not Debian 6/7/8/9/10/11/12 . No changes were made to the apt-get sources." && return 1;;
|
||||
6*) DEBIAN_RELEASE="squeeze" ;;
|
||||
7*) DEBIAN_RELEASE="wheezy" ;;
|
||||
8*) DEBIAN_RELEASE="jessie" ;;
|
||||
9*) DEBIAN_RELEASE="stretch" ;;
|
||||
10*) DEBIAN_RELEASE="buster" ;;
|
||||
11*) DEBIAN_RELEASE="bullseye" ;;
|
||||
12*) DEBIAN_RELEASE="bookworm" ;;
|
||||
*) echo "The system is not Debian 6/7/8/9/10/11/12 . No changes were made to the apt-get sources." && return 1 ;;
|
||||
esac
|
||||
|
||||
|
||||
# Write sources list in the desired format
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
cat >/etc/apt/sources.list <<EOF
|
||||
deb ${URL} ${DEBIAN_RELEASE} main contrib non-free
|
||||
deb ${URL} ${DEBIAN_RELEASE}-updates main contrib non-free
|
||||
deb ${URL} ${DEBIAN_RELEASE}-backports main contrib non-free
|
||||
|
@ -109,7 +109,7 @@ change_ubuntu_apt_sources() {
|
|||
# Check if the IP is in China
|
||||
ip=$(curl -s https://ipapi.co/ip)
|
||||
location=$(curl -s https://ipapi.co/$ip/country_name)
|
||||
|
||||
|
||||
# Check the system's Ubuntu version
|
||||
UBUNTU_VERSION=$(lsb_release -r | awk '{print $2}')
|
||||
|
||||
|
@ -123,19 +123,19 @@ change_ubuntu_apt_sources() {
|
|||
|
||||
# Set Ubuntu release based on Ubuntu version
|
||||
case $UBUNTU_VERSION in
|
||||
# 14*) UBUNTU_RELEASE="trusty";;
|
||||
16*) UBUNTU_RELEASE="xenial";;
|
||||
18*) UBUNTU_RELEASE="bionic";;
|
||||
20*) UBUNTU_RELEASE="focal";;
|
||||
22*) UBUNTU_RELEASE="groovy";;
|
||||
*) echo "The system is not Ubuntu 14/16/18/20/22 . No changes were made to the apt-get sources." && return 1;;
|
||||
# 14*) UBUNTU_RELEASE="trusty";;
|
||||
16*) UBUNTU_RELEASE="xenial" ;;
|
||||
18*) UBUNTU_RELEASE="bionic" ;;
|
||||
20*) UBUNTU_RELEASE="focal" ;;
|
||||
22*) UBUNTU_RELEASE="groovy" ;;
|
||||
*) echo "The system is not Ubuntu 14/16/18/20/22 . No changes were made to the apt-get sources." && return 1 ;;
|
||||
esac
|
||||
|
||||
|
||||
# 备份当前sources.list
|
||||
backup_source
|
||||
|
||||
|
||||
# Write sources list in the desired format
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
cat >/etc/apt/sources.list <<EOF
|
||||
deb ${URL} ${UBUNTU_RELEASE} main restricted universe multiverse
|
||||
deb ${URL} ${UBUNTU_RELEASE}-security main restricted universe multiverse
|
||||
deb ${URL} ${UBUNTU_RELEASE}-updates main restricted universe multiverse
|
||||
|
@ -159,9 +159,9 @@ check_eol_and_switch_apt_source() {
|
|||
if [ "$confirm" == "Y" ] || [ "$confirm" == "y" ]; then
|
||||
# 备份当前sources.list
|
||||
backup_source
|
||||
|
||||
|
||||
# 修改apt源
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
cat >/etc/apt/sources.list <<EOF
|
||||
deb http://old-releases.ubuntu.com/ubuntu/ $version main restricted universe multiverse
|
||||
deb http://old-releases.ubuntu.com/ubuntu/ $version-security main restricted universe multiverse
|
||||
deb http://old-releases.ubuntu.com/ubuntu/ $version-updates main restricted universe multiverse
|
||||
|
@ -184,7 +184,7 @@ fix_broken() {
|
|||
exit 0
|
||||
fi
|
||||
fi
|
||||
if apt-get install curl wget -y | grep -F -- '--fix-broken' ; then
|
||||
if apt-get install curl wget -y | grep -F -- '--fix-broken'; then
|
||||
apt-get --fix-broken install -y
|
||||
apt-get update
|
||||
if [ $? -eq 0 ]; then
|
||||
|
@ -204,15 +204,15 @@ fix_locked() {
|
|||
sudo rm /var/lib/dpkg/lock
|
||||
sudo rm /var/cache/apt/archives/lock
|
||||
fi
|
||||
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# Print a message indicating that the update was successful
|
||||
green "The apt-get update was successful."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
yellow "The update still failed. Attempting to fix missing GPG keys..."
|
||||
if [ -f /etc/debian_version ]; then
|
||||
|
@ -221,7 +221,7 @@ fix_locked() {
|
|||
red "try sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys missing key"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
output=$(apt-get update 2>&1)
|
||||
if echo $output | grep -q "NO_PUBKEY"; then
|
||||
echo "Some keys are missing, attempting to retrieve them now..."
|
||||
|
@ -241,14 +241,14 @@ fix_sources() {
|
|||
rm -rf update_output.log
|
||||
apt-get update 2>&1 | tee update_output.log
|
||||
exit_code=$?
|
||||
|
||||
|
||||
# Check the update output for "does not have a Release file" error
|
||||
if grep -Eq "does not have a Release file|Malformed entry" update_output.log; then
|
||||
# Check if the system is Ubuntu or Debian
|
||||
if [ -f /etc/os-release ]; then
|
||||
# Get the value of the ID variable
|
||||
ID=$(lsb_release -i | awk '{print $3}')
|
||||
|
||||
|
||||
# If the ID is ubuntu, run the change_ubuntu_apt_sources script
|
||||
if [ "$ID" == "ubuntu" ]; then
|
||||
yellow "ubuntu"
|
||||
|
@ -270,7 +270,7 @@ fix_sources() {
|
|||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Update the package list
|
||||
rm -rf update_output.log
|
||||
apt-get update 2>&1 | tee update_output.log
|
||||
|
@ -313,45 +313,44 @@ fix_sources() {
|
|||
}
|
||||
|
||||
fix_install() {
|
||||
# ps aux | grep apt
|
||||
sudo pkill apt
|
||||
|
||||
if lsof /var/lib/dpkg/lock > /dev/null 2>&1; then
|
||||
sudo kill $(sudo lsof /var/lib/dpkg/lock | awk '{print $2}')
|
||||
sudo rm /var/lib/dpkg/lock
|
||||
fi
|
||||
# ps aux | grep apt
|
||||
sudo pkill apt
|
||||
|
||||
if lsof /var/cache/apt/archives/lock > /dev/null 2>&1; then
|
||||
sudo kill $(sudo lsof /var/cache/apt/archives/lock | awk '{print $2}')
|
||||
sudo rm -rf /var/cache/apt/archives/lock
|
||||
fi
|
||||
if lsof /var/lib/dpkg/lock >/dev/null 2>&1; then
|
||||
sudo kill $(sudo lsof /var/lib/dpkg/lock | awk '{print $2}')
|
||||
sudo rm /var/lib/dpkg/lock
|
||||
fi
|
||||
|
||||
if sudo lsof /var/lib/apt/lists/lock > /dev/null 2>&1; then
|
||||
sudo kill $(sudo lsof /var/lib/apt/lists/lock | awk '{print $2}')
|
||||
sudo rm /var/lib/apt/lists/lock
|
||||
fi
|
||||
if lsof /var/cache/apt/archives/lock >/dev/null 2>&1; then
|
||||
sudo kill $(sudo lsof /var/cache/apt/archives/lock | awk '{print $2}')
|
||||
sudo rm -rf /var/cache/apt/archives/lock
|
||||
fi
|
||||
|
||||
sudo apt-get clean
|
||||
sudo apt-get update
|
||||
sudo dpkg --configure -a
|
||||
if sudo lsof /var/lib/apt/lists/lock >/dev/null 2>&1; then
|
||||
sudo kill $(sudo lsof /var/lib/apt/lists/lock | awk '{print $2}')
|
||||
sudo rm /var/lib/apt/lists/lock
|
||||
fi
|
||||
|
||||
sudo apt-get clean
|
||||
sudo apt-get update
|
||||
sudo dpkg --configure -a
|
||||
}
|
||||
|
||||
|
||||
check_again() {
|
||||
# Update the package list again to pick up the new sources
|
||||
apt_update_output=$(apt-get update 2>&1)
|
||||
echo "$apt_update_output" > "$temp_file_apt_fix"
|
||||
echo "$apt_update_output" >"$temp_file_apt_fix"
|
||||
if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then
|
||||
public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }')
|
||||
joined_keys=$(echo "$public_keys" | paste -sd " ")
|
||||
yellow "No Public Keys: ${joined_keys}"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${joined_keys}
|
||||
apt-get update
|
||||
public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }')
|
||||
joined_keys=$(echo "$public_keys" | paste -sd " ")
|
||||
yellow "No Public Keys: ${joined_keys}"
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${joined_keys}
|
||||
apt-get update
|
||||
fi
|
||||
rm "$temp_file_apt_fix"
|
||||
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
|
||||
# Check the exit status of the update command
|
||||
if [ $? -eq 0 ]; then
|
||||
# Print a message indicating that the update was successful
|
||||
|
@ -366,7 +365,6 @@ check_again() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
##############################################################################################################################################
|
||||
|
||||
head
|
||||
|
|
|
@ -13,10 +13,10 @@ else
|
|||
echo "Locale set to $utf8_locale"
|
||||
fi
|
||||
|
||||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||||
red() { echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||||
green() { echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||||
yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||||
reading() { read -rp "$(green "$1")" "$2"; }
|
||||
|
||||
head() {
|
||||
# 支持系统:Ubuntu 12+,Debian 6+
|
||||
|
@ -56,7 +56,7 @@ main() {
|
|||
backup_file="/etc/systemd/journald.conf-$(date +%Y%m%d%H%M%S).bak"
|
||||
sudo cp /etc/systemd/journald.conf "$backup_file"
|
||||
yellow "Backed up /etc/systemd/journald.conf to $backup_file"
|
||||
awk -v size="$size" '{ if ($1 == "SystemMaxUse=") { print "SystemMaxUse=" size } else { print $0 } }' /etc/systemd/journald.conf > "$temp_file"
|
||||
awk -v size="$size" '{ if ($1 == "SystemMaxUse=") { print "SystemMaxUse=" size } else { print $0 } }' /etc/systemd/journald.conf >"$temp_file"
|
||||
sudo cp "$temp_file" /etc/systemd/journald.conf
|
||||
rm -rf "$temp_file"
|
||||
conf_file="/etc/systemd/journald.conf"
|
||||
|
@ -65,25 +65,23 @@ main() {
|
|||
new_value1="128M"
|
||||
new_value2="no"
|
||||
if [[ ! -f "$conf_file" ]]; then
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
if grep -q "^$variable1=" "$conf_file"; then
|
||||
sed -i "s/^$variable1=.*/$variable1=$new_value1/" "$conf_file"
|
||||
sed -i "s/^$variable1=.*/$variable1=$new_value1/" "$conf_file"
|
||||
else
|
||||
echo "$variable1=$new_value1" >> "$conf_file"
|
||||
echo "$variable1=$new_value1" >>"$conf_file"
|
||||
fi
|
||||
if grep -q "^$variable2=" "$conf_file"; then
|
||||
sed -i "s/^$variable2=.*/$variable2=$new_value2/" "$conf_file"
|
||||
sed -i "s/^$variable2=.*/$variable2=$new_value2/" "$conf_file"
|
||||
else
|
||||
echo "$variable2=$new_value2" >> "$conf_file"
|
||||
echo "$variable2=$new_value2" >>"$conf_file"
|
||||
fi
|
||||
systemctl restart systemd-journald
|
||||
|
||||
green "change /etc/systemd/journald.conf successfully"
|
||||
}
|
||||
|
||||
|
||||
|
||||
level() {
|
||||
# Set default values for variables
|
||||
log_level=warning
|
||||
|
@ -97,8 +95,7 @@ level() {
|
|||
find "$journald_log_dir" -mtime +$retention_days -exec rm {} \;
|
||||
green "change $journald_log_dir successfully"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Check if config file exists
|
||||
if [ ! -f /etc/rsyslog.conf ]; then
|
||||
red "Config file (/etc/rsyslog.conf) not found, so not modify" >&2
|
||||
|
@ -109,10 +106,10 @@ level() {
|
|||
sudo cp /etc/rsyslog.conf "$backup_file"
|
||||
yellow "Backed up /etc/rsyslog.conf to $backup_file"
|
||||
if grep -q "loglevel" /etc/rsyslog.conf; then
|
||||
awk -v log_level="$log_level" '{ if ($1 == "loglevel") { print "loglevel = " log_level } else { print $0 } }' /etc/rsyslog.conf > "$temp_file"
|
||||
awk -v log_level="$log_level" '{ if ($1 == "loglevel") { print "loglevel = " log_level } else { print $0 } }' /etc/rsyslog.conf >"$temp_file"
|
||||
else
|
||||
cat /etc/rsyslog.conf > "$temp_file"
|
||||
echo "loglevel = $log_level" >> "$temp_file"
|
||||
cat /etc/rsyslog.conf >"$temp_file"
|
||||
echo "loglevel = $log_level" >>"$temp_file"
|
||||
fi
|
||||
sudo cp "$temp_file" /etc/rsyslog.conf
|
||||
rm "$temp_file"
|
||||
|
@ -126,7 +123,7 @@ check_again() {
|
|||
count=0
|
||||
while [ $count -lt 5 ]; do
|
||||
journalctl --disk-usage
|
||||
count=$((count+1))
|
||||
count=$((count + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user