#!/bin/bash # systemd 开机启动服务 echo "############# 宿主机 设置 bois 上电开机,和 systemd 开机启动服务 ####################" echo " 步骤1:进入BIOS界面 重启计算机并在开机过程中按下相应的按键(通常是Del、F2、F10等)来进入BIOS界面。这个按键可能因计算机品牌而异。 步骤2:寻找电源恢复选项(或者电源管理) 在BIOS界面中,浏览各个选项寻找与电源恢复相关的设置。通常,这个选项会被标记为“AC Power Recovery”、“Power on after power failure”等。 " echo " # 端口代理 stream { upstream www22 { server 192.168.122.80:22; } upstream www62010 { server 192.168.122.80:62010; } upstream www62011 { server 192.168.122.80:62011; } upstream www3000 { server 192.168.122.80:3000; } upstream www3306 { server 192.168.122.80:3306; } upstream TXvpn { server 192.168.122.81:22; } upstream win3389 { server 192.168.122.100:3389; } server { listen 10080; proxy_pass www22; } server { listen 62010; proxy_pass www62010; } server { listen 62011; proxy_pass www62011; } server { listen 3000; proxy_pass www3000; } server { listen 3306; proxy_pass www3306; } server { listen 10081; proxy_pass TXvpn; } server { listen 13389; proxy_pass win3389; } } " os_release() { if [ $USER = "root" ] then sudoc=" " # 判断字符串的等号要加空格,否则无法判断 else sudoc="sudo" echo "当前为普通用户,需要输入root 密码... $sudoc" $sudoc date ; fi xitong=` cat /etc/os-release | grep -w ID | awk -F"=" '{print $2}' | sed "s/\"//g" ` case "$xitong" in "centos" ) aptc="yum" ; dpkgc="rpm -qa " ; echo "当前是 centos 系统" ;; "ubuntu" ) aptc="apt" ; dpkgc="dpkg -l " ; echo "当前是 ubuntu 系统" ;; esac } os_release kaiji_web_service(){ # ubuntu 以 systemd 服务方式,自动启动服务软件 systemdDir="/usr/lib/systemd/system" ServiceName="eisc_web_start.service" cd $systemdDir ; $sudoc touch $ServiceName ; $sudoc chmod 777 $ServiceName #----- 写入 start.service 服务 -----# echo " [Unit] Description=start web [Service] Type=forking ExecStart=/etc/init.d/shell/start.sh ExecReload=/bin/kill -SIGHUP \$MAINPID ExecStop=/bin/kill -SIGINT \$MAINPID [Install] WantedBy=multi-user.target " > $ServiceName $sudoc apt install dos2unix -y $sudoc dos2unix $ServiceName # 转为 unix 格式,否则可能出现字符乱码 $sudoc chmod 644 $ServiceName $sudoc systemctl daemon-reload $sudoc systemctl disable $ServiceName $sudoc systemctl enable $ServiceName cd } kaiji_start_web_sh(){ $sudoc mkdir -p /etc/init.d/shell/ ; $sudoc chmod 777 /etc/init.d/shell/ if [ ! -e /etc/init.d/shell/openvpn_connect.sh ] then wget eisc.cn/file/ubuntu/shell/server/openvpn_connect.sh -O /etc/init.d/shell/openvpn_connect.sh fi read -p "是否继续进行配置 systemd 开机启动? y/n: " kaijisz if [ "$kaijisz" = "y" ] then kaiji_web_service # 启动这个函数 $sudoc mkdir -p $installdir/shell ; $sudoc chmod 777 -R $installdir/shell # 将脚本授权给 root 用户 echo "#!/bin/bash # bash 解释器 一定要在第一行 开头写,否则下面脚本不执行,开机启动不成功。 由于是 service服务,因此此脚本是 root 用户执行 #mount -t nfs -o rw,hard,intr 192.168.122.1:/datadisk/eisc /datadisk/eisc/ ; sleep 2 # /datadisk/eisc/server/nginx/nginx199/sbin/nginx & # /datadisk/eisc/server/gitea/gitea & virsh start ubuntu20_Tencent_VPN virsh start www virsh start win10 # 宿主机启动 #/etc/init.d/shell/openvpn_connect.sh & # vpn 服务器 touch $HOME/log_start_web.txt ; chmod 777 $HOME/log_start_web.txt " > /etc/init.d/shell/start.sh echo "#----------------- 查看写入的开机启动脚本 -------------------#" cat /etc/init.d/shell/start.sh $sudoc chmod +x /etc/init.d/shell/* $sudoc chown -R root:root /etc/init.d/shell/* ; $sudoc chmod 777 -R /etc/init.d/shell/* else echo "[ok]目前不配置systemd " fi } kaiji_start_web_sh
Powered by ddoss.cn 12.0
©2015 - 2024 ddoss
渝公网安备50011302222260号 渝ICP备2024035333号 【实验平台安全承诺书】 小绿叶技术社区,优化网络中,点击查看配置信息
您的IP:192.168.122.82,2024-10-10 18:05:55,Processed in 0.02928 second(s).