-
Mockingbird 说:
@ChatGPT 请告诉我Nginx系统重写规则
好的,Nginx系统重写规则非常灵活,可以根据需求进行自定义配置。以下是一些常见的系统重写规则示例:
- 重定向到www域名:
server { listen 80; server_name example.com; return 301 $scheme://www.example.com$request_uri; }
- 重定向到https:
server { listen 80; server_name example.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name example.com; ... }
- 移除URL中的文件扩展名:
location / { try_files $uri $uri/ $uri.html =404; }
- 使用URL重写规则实现RESTful API:
location /api/ { rewrite ^/api/(?[^/]+)/?$ /api.php?resource=$resource last; rewrite ^/api/(?[^/]+)/(?[^/]+)/?$ /api.php?resource=$resource&id=$id last; }
上述是一些常见的Nginx系统重写规则示例,你可以根据自己的需求进行自定义配置。更多Nginx系统重写规则可以参考Nginx的官方文档。
-
scintist 说:
@ChatGPT 学习习近平总书记在主持二十届中共中央政治局第二次集体学习时发表的重要讲话,包括三个部分,分别是简略内容、提出的工作要求、采取的措施
好的,以下是我为您整理的内容:
一、简略内容:
2018年11月30日,习近平总书记主持召开二十届中共中央政治局第二次集体学习并发表了重要讲话。讲话围绕着“不忘初心,牢记使命”主题,强调了中国共产党要保持初心使命,勇于担当作为,不断提高解决问题的本领,推动中国特色社会主义事业不断向前推进。
二、提出的工作要求:
习近平总书记在讲话中提出了以下三点工作要求:
-
坚定初心使命,永葆共产党人本色。要求全党同志要坚守共产党人的信仰、理想、信念,牢记自己的党员身份,时刻保持争取人民利益的初心和使命。
-
突出问题导向,加强解决问题的本领。要求全党同志要高度关注、研究和解决当前面临的各项问题,强化问题导向思维,不断提高解决问题的本领。
-
推动全面从严治党向纵深发展。要求全党同志要重视党内政治生活,加强自身建设,不断增强党的执政能力和领导水平,着力解决党内存在的风险和问题。
三、采取的措施:
习近平总书记在讲话中采取了以下三个措施:
-
推动党员干部切实落实党的基本路线。要求全党同志要自觉维护党的基本路线,确保全党人民不断前进。
-
引导党员干部健康成长。要求全党同志要注重培养自己的道德修养和党性修养,加强个人职业能力和素质的提升,努力成为有用之才。
-
建立健全制度体系。要求全党同志要适应新时代的需要,加强制度建设,落实好管党治党的各项制度和措施,确保全面从严治党向纵深发展。
-
-
scintist 说:
@ChatGPT “新发展格局以现代化产业体系为基础,经济循环畅通需要各产业有序链接、高效畅通。要继续把发展经济的着力点放在实体经济上,扎实推进新型工业化,加快建设制造强国、质量强国、网络强国、数字中国,打造具有国际竞争力的数字产业集群”这段话在通信行业领域有哪些工作要求,下一步工作措施有哪些
这段话强调了新发展格局需要实现经济循环畅通,打造具有国际竞争力的数字产业集群,并特别提到了要推进网络强国和数字中国建设。下面是针对通信行业领域的工作要求和下一步工作措施:
-
稳步推进5G建设:5G是数字经济时代的基础设施,是一个强大的综合平台,通信行业需要加强5G网络建设、频谱规划、商用应用等方面的投入。
-
推进宽带网络建设:要深入推进“宽带中国”建设,持续加强宽带网络基础建设和提升网络速度,以提高数据传输的效率和准确性。
-
大力发展物联网:将传统通信行业与物联网技术结合起来,发展智能家居、智慧城市等方面的应用,提高生产效率和人民生活质量。
-
提高可靠性、稳定性、安全性:在网络运行过程中,需要考虑通信网络的可靠性、稳定性和安全性等因素,为广大用户提供高品质的通信服务。
-
发展数字化产业:加快通信行业向数字化、网络化、智能化转型,推动数字化产业的发展,完善产业链及商业模式,打造数字产业集群。
为实现这些工作要求,下一步通信行业可能采取以下措施:
-
加大技术研发和投入力度,完善网络设施及技术规范。
-
推动技术创新和实用应用的结合,推广5G、物联网等领先技术。
-
完善通信服务质量监管体系,严格监管通信企业的管理和运营。
-
加强与其他产业的联动合作,全面推进数字化产业的发展。
-
加强国际合作,与其他国家或地区分享技术和资源,推动行业全球化发展。
-
-
dianka2 说:
@ChatGPT 焊机焊接最后多厚的铁板,有什么要求?
焊机焊接铁板的厚度取决于所使用的焊机类型和规格,以及焊接工艺的操作技能。一般来说,手摇电焊机适合焊接较薄的铁板,一般不超过5毫米,而气体保护焊或电弧焊等高级焊接方法可以焊接更厚的铁板,甚至可以达到数十毫米的厚度。
在选择焊接铁板时,需要考虑以下一些要求:
1.焊材的选取: 应选择与被焊件材料相同的焊材, 或相似的焊材.
2.焊接条件: 需要掌握好电流、电压、电极大小、每厘米开弧次数的控制及其他焊接条件.
3.表面准备:焊前应做好被焊件表面的清洁和处理,以避免焊缝质量不佳。
4.操作技能:需要熟练的焊接技能及经验,能够准确地掌握焊接温度,焊接速度等参数。
总的来说,除了考虑材料厚度,选择合适的焊接方法、焊材和技术方案,以及准确掌握焊接参数和技能是焊接铁板要求的关键。
-
scintist 说:
@ChatGPT 如何理解“要完整、准确、全面贯彻新发展理念,加快构建新发展格局,着力推动高质量发展”
“要完整、准确、全面贯彻新发展理念,加快构建新发展格局,着力推动高质量发展”,是指在当前中国社会经济发展的背景下,需要坚持新发展理念,以加快构建新的发展格局,着力推动高质量的经济发展。
其中,“完整、准确、全面贯彻新发展理念”意味着在各个方面和各个阶段都要贯彻新发展理念,这可以使经济和社会发展更加科学和可持续。
“加快构建新发展格局”则是指在众多的制度和政策保障的基础上,深化各种改革,努力推动经济的新发展形态和新产业的发展,为全国经济持续快速发展提供保障。
最后,“着力推动高质量发展”是指通过有效的科学系统和可行的手段,在不断提升经济发展效益和质量的同时,还必须加快创新,提高科技水平和创新能力,增强核心竞争力,使中国的经济发展能够更快更好地增长,更加优势地面向未来,更加符合人民群众的根本利益和期待。
-
@ChatGPT #!/bin/bash
argv=$1
#deploy=$1
count=0
filename=()
isTar=1
if [ $isTar == "1" ]
thenpath=
cd $(dirname $0);pwd -P
#echo the current path is:$path
for i inls
do
filegz="tar.gz"
if [[ $i == $filegz ]]
then
#echo $i
filename[count]=$i
count=expr $count + 1
fi
done#echo $count
#echo ${filename[@]}
for((n=0;n<${#filename[@]};n++)){
echo -e "\033[40;35m"$n"\033[0m \033[40;32m"${filename[n]}"\033[0m"
}if (("$count" <= "0"));
then
echo "请下载部署包"
exit
elif (("$count" == "1"));
then
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
else
echo -e "\033[40;36m 请选择部署包:\033[0m"
read inNum
if (("$inNum" < "0")) || (("$inNum" >= "$count"))
then
echo "索引错误"
exit
else
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
fi
fi
fi#echo "解压部署包"
#echo $deploy
#tar -zxvf $deploy
#echo "解压部署包完成"inspect(){
if [ $argv != "PBox16.04" ];
then
cp -rf /mnt/profile /etc/
fi
if [ ! -d "/mnt/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/mnt/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ]; then cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/ ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2 fi sed -i '/source/d' /etc/init.d/rc.local sed -i '$a source /mnt/run.sh' /etc/init.d/rc.local #taosd &>/dev/null echo "历史数据库安装完成"
}
inspectPBox(){
if [ ! -d "/pbox/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/pbox/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ]; then cp -rf /pbox/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/ ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2 fi #taosd &>/dev/null echo "历史数据库安装完成"
}
echo "拷贝系统文件"
if [ $argv == "8401d" ];
then
cp -rf ./libstdc++.so.6 /usr/lib/arm-linux-gnueabihf/
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
fiif [ $argv == "ISG" ];
then
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
ln -sf /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/libstdc++.so.6if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /mnt/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fi
fiecho "拷贝系统文件完成"
echo -e "\033[40;36m 网口选择 单网(1)双网(2) \033[0m"
read input
#echo $input
if [ $input == "1" ];
then
sed -i 's/NetCardCount = "2"/NetCardCount = "1"/g' /mnt/FCloudComm/bin/pSL_Setting.xml
sed -i '/sleep 1/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/ifconfig eth1 192.168.20.101 netmask 255.255.255.0 up/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/route add default gw 192.168.20.1 dev eth1/d' /mnt/FCloudComm/tools/IPCfg
fi
echo "网口配置完成"#4G函数
echo -e "\033[40;36m 是否支持4G? 否(0)是(1) \033[0m"read -p "" number
if [ $number -eq 0 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
fiif [ $argv == "PBox" ]; then sed -i '/quectel-pppd.sh/d' /pbox/run.sh fi if [ $argv == "PBox16.04" ]; then sed -i '/quectel-pppd.sh/d' /mnt/run.sh fi
fi
if [ $number -eq 1 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
sed -i '/sleep 10/i\sh ./active4g.sh &' /mnt/run.sh
fiif [ $argv == "PBox" ]; then sed -i '/quectel-pppd.sh/d' /pbox/run.sh sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /pbox/run.sh fi if [ $argv == "PBox16.04" ]; then sed -i '/quectel-pppd.sh/d' /mnt/run.sh sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /mnt/run.sh fi
fi
if [ $number -ne 1 ] && [ $number -ne 0 ];
then
echo "输入错误"
fiecho "配置开机启动"
if [ $argv == "8401d" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rc.local
fiif [ $argv == "PBox16.04" ];
then
sed -i '1c #! /bin/bash' /etc/rc.local
fiif [ $argv == "ISG" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rocktech.sh
sed -i '$a source /mnt/run.sh' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rc.local
sed -i "114s:#::g" /etc/init.d/rocktech.sh
fiecho "配置开机启动完成"
echo "初始化本地ip地址"
sed -i 's/address 190.5.20.171/address 192.168.10.101/g' /etc/network/interfaces
sed -i 's/gateway 190.5.200.11/gateway 192.168.10.1/g' /etc/network/interfaces
sed -i 's/address 192.168.1.100/address 192.168.20.101/g' /etc/network/interfaces
sed -i 's/gateway 192.168.1.1/gateway 192.168.20.1/g' /etc/network/interfaces
echo "初始化本地ip地址结束"echo "配置历史数据库"
#td库ISG网关配置
td(){
cd /mnt/TDengine-server-2.0.10.0/
./install.sh &>/dev/null
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
sed -i 's/# fqdn/fqdn/g' /etc/taos/taos.cfg
sed -i 's/hostname/localhost/g' /etc/taos/taos.cfg
}#PBox网关配置
PB(){
if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /pbox/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fised -i '1c #! /bin/bash' /etc/init.d/rc.local cd /pbox/TDengine-server-2.0.10.0 ./install.sh &>/dev/null sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg sed -i 's/# logDir/ logDir/g' /etc/taos/taos.cfg sed -i 's/# dataDir/ dataDir/g' /etc/taos/taos.cfg sed -i 's#/var/log/taos#/pbox/log#g' /etc/taos/taos.cfg sed -i 's#/var/lib/taos#/pbox/lib#g' /etc/taos/taos.cfg sed -i '/run.sh/d' /etc/rc5.d/S99rmnologin.sh sed -i '$a source /pbox/run.sh' /etc/rc5.d/S99rmnologin.sh
}
power(){
source /mnt/FCloudComm/tools/setEnv.sh
if [ -d "/mnt/config" ];then
#echo "文件夹存在"if [ -f "/mnt/config/hardwareinfo.HID" ];then #echo "文件存在" cp -rf /mnt/config/hardwareinfo.HID /mnt/FCloudComm else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /mnt/FCloudComm/bin/getID fi if [ -f "/mnt/config/"*".lic" ];then #echo "文件存在" cp -rf /mnt/config/*.lic /mnt/FCloudComm/bin else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /mnt/FCloudComm/bin/getID fi else #echo "文件夹不存在" echo "配置完成 请放入HID 和 授权文件" /mnt/FCloudComm/bin/getID fi #echo "配置完成 请放入HID 和 授权文件" #/mnt/FCloudComm/bin/getID
}
powerPBox(){
source /pbox/FCloudComm/tools/setEnv.sh
if [ -d "/pbox/config" ];then
#echo "文件夹存在"if [ -f "/pbox/config/hardwareinfo.HID" ];then #echo "文件存在" cp -rf /pbox/config/hardwareinfo.HID /pbox/FCloudComm else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /pbox/FCloudComm/bin/getID fi if [ -f "/pbox/config/"*".lic" ];then #echo "文件存在" cp -rf /pbox/config/*.lic /pbox/FCloudComm/bin else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /pbox/FCloudComm/bin/getID fi else #echo "文件夹不存在" echo "配置完成 请放入HID 和 授权文件" /pbox/FCloudComm/bin/getID fi #echo "配置完成 请放入HID 和 授权文件" #/pbox/FCloudComm/bin/getID
}
case "$1" in
8401d)
cd /mnt/TDengine-server-2.0.10.0
./install.sh &>/dev/null
sed -i 's#/third/log#log#g' /etc/taos/taos.cfg
sed -i 's#/third/data#data#g' /etc/taos/taos.cfg
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
inspect
power
;;
8316)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 GEA-8316-DLK" ];
then
i="1"
fi
done < /etc/hostsif [ "$i" != "1" ]; then sed -i '$a\127.0.0.1 GEA-8316-DLK' /etc/hosts fi cd /mnt/TDengine-server-2.0.10.0 ./install.sh &>/dev/null sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg inspect power ;; ISG) i="0" while read path do if [ "$path" == "127.0.0.1 localhost" ]; then i="1" fi done < /etc/hosts if [ "$i" != "1" ]; then echo "127.0.0.1 localhost"> /etc/hosts fi td inspect power ;; PBox) i="0" while read path do if [ "$path" == "127.0.0.1 imx6ull14x14evk" ]; then i="1" fi done < /etc/hosts if [ "$i" != "1" ]; then echo "127.0.0.1 imx6ull14x14evk"> /etc/hosts fi PB inspectPBox powerPBox ;; PBox16.04) pkexec chown root:root /etc/sudoers /etc/sudoers.d -R td inspect power sed -i '/source/d' /etc/init.d/rc.local sed -i '/source/d' /etc/rc.local sed -i '/sleep 1/isource /mnt/run.sh' /etc/rc.local ;;
esac
用python重写
-
for culture 说:
@ChatGPT #!/bin/bash
argv=$1
#deploy=$1
count=0
filename=()
isTar=1
if [ $isTar == "1" ]
thenpath=
cd $(dirname $0);pwd -P
#echo the current path is:$path
for i inls
do
filegz="tar.gz"
if [[ $i == $filegz ]]
then
#echo $i
filename[count]=$i
count=expr $count + 1
fi
done#echo $count
#echo ${filename[@]}
for((n=0;n echo -e "\033[40;35m"$n"\033[0m \033[40;32m"${filename[n]}"\033[0m"
}if (("$count" then
echo "请下载部署包"
exit
elif (("$count" == "1"));
then
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
else
echo -e "\033[40;36m 请选择部署包:\033[0m"
read inNum
if (("$inNum" = "$count"))
then
echo "索引错误"
exit
else
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
fi
fi
fi#echo "解压部署包"
#echo $deploy
#tar -zxvf $deploy
#echo "解压部署包完成"inspect(){
if [ $argv != "PBox16.04" ];
then
cp -rf /mnt/profile /etc/
fi
if [ ! -d "/mnt/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/mnt/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ];
then
cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2
fised -i '/source/d' /etc/init.d/rc.local
sed -i '$a source /mnt/run.sh' /etc/init.d/rc.local#taosd &>/dev/null
echo "历史数据库安装完成"}
inspectPBox(){
if [ ! -d "/pbox/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/pbox/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ];
then
cp -rf /pbox/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2
fi#taosd &>/dev/null
echo "历史数据库安装完成"}
echo "拷贝系统文件"
if [ $argv == "8401d" ];
then
cp -rf ./libstdc++.so.6 /usr/lib/arm-linux-gnueabihf/
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
fiif [ $argv == "ISG" ];
then
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
ln -sf /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/libstdc++.so.6if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /mnt/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fi
fiecho "拷贝系统文件完成"
echo -e "\033[40;36m 网口选择 单网(1)双网(2) \033[0m"
read input
#echo $input
if [ $input == "1" ];
then
sed -i 's/NetCardCount = "2"/NetCardCount = "1"/g' /mnt/FCloudComm/bin/pSL_Setting.xml
sed -i '/sleep 1/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/ifconfig eth1 192.168.20.101 netmask 255.255.255.0 up/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/route add default gw 192.168.20.1 dev eth1/d' /mnt/FCloudComm/tools/IPCfg
fi
echo "网口配置完成"#4G函数
echo -e "\033[40;36m 是否支持4G? 否(0)是(1) \033[0m"read -p "" number
if [ $number -eq 0 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
fiif [ $argv == "PBox" ];
then
sed -i '/quectel-pppd.sh/d' /pbox/run.sh
fiif [ $argv == "PBox16.04" ];
then
sed -i '/quectel-pppd.sh/d' /mnt/run.sh
fi
fiif [ $number -eq 1 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
sed -i '/sleep 10/i\sh ./active4g.sh &' /mnt/run.sh
fiif [ $argv == "PBox" ];
then
sed -i '/quectel-pppd.sh/d' /pbox/run.sh
sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /pbox/run.sh
fiif [ $argv == "PBox16.04" ];
then
sed -i '/quectel-pppd.sh/d' /mnt/run.sh
sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /mnt/run.sh
fi
fiif [ $number -ne 1 ] && [ $number -ne 0 ];
then
echo "输入错误"
fiecho "配置开机启动"
if [ $argv == "8401d" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rc.local
fiif [ $argv == "PBox16.04" ];
then
sed -i '1c #! /bin/bash' /etc/rc.local
fiif [ $argv == "ISG" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rocktech.sh
sed -i '$a source /mnt/run.sh' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rc.local
sed -i "114s:#::g" /etc/init.d/rocktech.sh
fiecho "配置开机启动完成"
echo "初始化本地ip地址"
sed -i 's/address 190.5.20.171/address 192.168.10.101/g' /etc/network/interfaces
sed -i 's/gateway 190.5.200.11/gateway 192.168.10.1/g' /etc/network/interfaces
sed -i 's/address 192.168.1.100/address 192.168.20.101/g' /etc/network/interfaces
sed -i 's/gateway 192.168.1.1/gateway 192.168.20.1/g' /etc/network/interfaces
echo "初始化本地ip地址结束"echo "配置历史数据库"
#td库ISG网关配置
td(){
cd /mnt/TDengine-server-2.0.10.0/
./install.sh &>/dev/null
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
sed -i 's/# fqdn/fqdn/g' /etc/taos/taos.cfg
sed -i 's/hostname/localhost/g' /etc/taos/taos.cfg
}#PBox网关配置
PB(){
if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /pbox/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fised -i '1c #! /bin/bash' /etc/init.d/rc.local
cd /pbox/TDengine-server-2.0.10.0
./install.sh &>/dev/null
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
sed -i 's/# logDir/ logDir/g' /etc/taos/taos.cfg
sed -i 's/# dataDir/ dataDir/g' /etc/taos/taos.cfg
sed -i 's#/var/log/taos#/pbox/log#g' /etc/taos/taos.cfg
sed -i 's#/var/lib/taos#/pbox/lib#g' /etc/taos/taos.cfgsed -i '/run.sh/d' /etc/rc5.d/S99rmnologin.sh
sed -i '$a source /pbox/run.sh' /etc/rc5.d/S99rmnologin.sh
}power(){
source /mnt/FCloudComm/tools/setEnv.sh
if [ -d "/mnt/config" ];then
#echo "文件夹存在"if [ -f "/mnt/config/hardwareinfo.HID" ];then
#echo "文件存在"
cp -rf /mnt/config/hardwareinfo.HID /mnt/FCloudComm
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/mnt/FCloudComm/bin/getID
fiif [ -f "/mnt/config/"".lic" ];then
#echo "文件存在"
cp -rf /mnt/config/.lic /mnt/FCloudComm/bin
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/mnt/FCloudComm/bin/getID
fielse
#echo "文件夹不存在"
echo "配置完成 请放入HID 和 授权文件"
/mnt/FCloudComm/bin/getID
fi
#echo "配置完成 请放入HID 和 授权文件"
#/mnt/FCloudComm/bin/getID
}powerPBox(){
source /pbox/FCloudComm/tools/setEnv.sh
if [ -d "/pbox/config" ];then
#echo "文件夹存在"if [ -f "/pbox/config/hardwareinfo.HID" ];then
#echo "文件存在"
cp -rf /pbox/config/hardwareinfo.HID /pbox/FCloudComm
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/pbox/FCloudComm/bin/getID
fiif [ -f "/pbox/config/"".lic" ];then
#echo "文件存在"
cp -rf /pbox/config/.lic /pbox/FCloudComm/bin
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/pbox/FCloudComm/bin/getID
fielse
#echo "文件夹不存在"
echo "配置完成 请放入HID 和 授权文件"
/pbox/FCloudComm/bin/getID
fi
#echo "配置完成 请放入HID 和 授权文件"
#/pbox/FCloudComm/bin/getID
}case "$1" in
8401d)
cd /mnt/TDengine-server-2.0.10.0
./install.sh &>/dev/null
sed -i 's#/third/log#log#g' /etc/taos/taos.cfg
sed -i 's#/third/data#data#g' /etc/taos/taos.cfg
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
inspect
power
;;
8316)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 GEA-8316-DLK" ];
then
i="1"
fi
done
if [ "$i" != "1" ];
then
sed -i '$a\127.0.0.1 GEA-8316-DLK' /etc/hosts
ficd /mnt/TDengine-server-2.0.10.0 ./install.sh &>/dev/null sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg inspect power ;;
ISG)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 localhost" ];
then
i="1"
fi
done
if [ "$i" != "1" ];
then
echo "127.0.0.1 localhost"> /etc/hosts
fitd inspect power ;;
PBox)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 imx6ull14x14evk" ];
then
i="1"
fi
done
if [ "$i" != "1" ];
then
echo "127.0.0.1 imx6ull14x14evk"> /etc/hosts
fi
PB
inspectPBox
powerPBox
;;
PBox16.04)
pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
td
inspect
power
sed -i '/source/d' /etc/init.d/rc.local
sed -i '/source/d' /etc/rc.local
sed -i '/sleep 1/isource /mnt/run.sh' /etc/rc.local
;;
esac用python重写
把原先的bash脚本用Python来实现,具体如下:
#!/usr/bin/env python3 import os import sys def deploy_package(argv): count = 0 filename = [] is_tar = 1 path = os.path.abspath(os.path.dirname(__file__)) for file in os.listdir(path): if is_tar and file.endswith(".tar.gz"): filename.append(file) count += 1 if count = count: print("索引错误") sys.exit() else: tar_path = "/pbox" if argv == "PBox" else "/mnt" os.system(f"tar zxvf {filename[inNum]} -C {tar_path}") def system_init(argv): if argv != "PBox16.04": os.system("cp -rf /mnt/profile /etc/") if not os.path.isdir("/mnt/FCloudComm"): print("1") sys.exit() if not os.path.isfile("/mnt/run.sh"): print("2") sys.exit() if not os.path.isfile("/usr/lib/libiconv.so.2.6.1"): os.system("cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2") with open("/etc/init.d/rc.local", "r+") as f: lines = f.readlines() f.seek(0) for l in lines: if "source" not in l: f.write(l) f.write("source /mnt/run.sh\n") print("历史数据库安装完成") def system_init_pbox(): if not os.path.isdir("/pbox/FCloudComm"): print("1") sys.exit() if not os.path.isfile("/pbox/run.sh"): print("2") sys.exit() if not os.path.isfile("/usr/lib/libatomic.so.1.0.
-
@ChatGPT #!/usr/bin/env python3
import os
import sysdef deploy_package(argv):
count = 0
filename = []
is_tar = 1
path = os.path.abspath(os.path.dirname(file))for file in os.listdir(path): if is_tar and file.endswith(".tar.gz"): filename.append(file) count += 1 if count = count: print("索引错误") sys.exit() else: tar_path = "/pbox" if argv == "PBox" else "/mnt" os.system(f"tar zxvf {filename[inNum]} -C {tar_path}")
def system_init(argv):
if argv != "PBox16.04":
os.system("cp -rf /mnt/profile /etc/")
if not os.path.isdir("/mnt/FCloudComm"):
print("1")
sys.exit()
if not os.path.isfile("/mnt/run.sh"):
print("2")
sys.exit()if not os.path.isfile("/usr/lib/libiconv.so.2.6.1"): os.system("cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2") with open("/etc/init.d/rc.local", "r+") as f: lines = f.readlines() f.seek(0) for l in lines: if "source" not in l: f.write(l) f.write("source /mnt/run.sh\n") print("历史数据库安装完成")
def system_init_pbox():
if not os.path.isdir("/pbox/FCloudComm"):
print("1")
sys.exit()
if not os.path.isfile("/pbox/run.sh"):
print("2")
sys.exit()if not os.path.isfile("/usr/lib/libatomic.so.1.0.
解释一下这段代码
-
for culture 说:
@ChatGPT #!/usr/bin/env python3
import os
import sysdef deploy_package(argv):
count = 0
filename = []
is_tar = 1
path = os.path.abspath(os.path.dirname(file))for file in os.listdir(path): if is_tar and file.endswith(".tar.gz"): filename.append(file) count += 1 if count = count: print("索引错误") sys.exit() else: tar_path = "/pbox" if argv == "PBox" else "/mnt" os.system(f"tar zxvf {filename[inNum]} -C {tar_path}")
def system_init(argv):
if argv != "PBox16.04":
os.system("cp -rf /mnt/profile /etc/")
if not os.path.isdir("/mnt/FCloudComm"):
print("1")
sys.exit()
if not os.path.isfile("/mnt/run.sh"):
print("2")
sys.exit()if not os.path.isfile("/usr/lib/libiconv.so.2.6.1"): os.system("cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2") with open("/etc/init.d/rc.local", "r+") as f: lines = f.readlines() f.seek(0) for l in lines: if "source" not in l: f.write(l) f.write("source /mnt/run.sh\n") print("历史数据库安装完成")
def system_init_pbox():
if not os.path.isdir("/pbox/FCloudComm"):
print("1")
sys.exit()
if not os.path.isfile("/pbox/run.sh"):
print("2")
sys.exit()if not os.path.isfile("/usr/lib/libatomic.so.1.0.
解释一下这段代码
这段代码是一个Python脚本,包含两个函数:deploy_package和system_init。主要功能用于自动化部署和初始化Linux系统中的一些组件和文件。
deploy_package函数接收一个参数,作为要安装的组件名称。首先获取当前目录下所有以.tar.gz结尾的文件,如果没有找到任何相关文件,则打印“索引错误”并退出。否则,根据参数值选择部署到不同的目录中,并使用tar命令解压缩指定的.tal.gz文件到目标目录中。
system_init函数有两个版本:其中一个接收一个参数(非PBox16.04),另一个没有参数。这个函数的主要目的是初始化Linux系统,主要包括以下几个方面:
- 复制/mnt/profile到/etc/目录下。
- 检查/mnt/FCloudComm、/mnt/run.sh文件是否存在或已创建。
- 检查/usr/lib/libiconv.so.2.6.1文件是否存在或已创建。
- 最后将source /mnt/run.sh添加到/etc/rc.local中。
如果是system_init_pbox,主要检查/pbox/FCloudComm、/pbox/run.sh文件是否存在或已创建,并检查/usr/lib/libatomic.so.1.0.文件是否存在或已创建。
最后一个if条件可能被中断了,缺少右括号.
-
@ChatGPT 用python重写如下脚本,输出完整代码并给出注释
#!/bin/bash
argv=$1
#deploy=$1
count=0
filename=()
isTar=1
if [ $isTar == "1" ]
thenpath=
cd $(dirname $0);pwd -P
#echo the current path is:$path
for i inls
do
filegz="tar.gz"
if [[ $i == $filegz ]]
then
#echo $i
filename[count]=$i
count=expr $count + 1
fi
done#echo $count
#echo ${filename[@]}
for((n=0;n<${#filename[@]};n++)){
echo -e "\033[40;35m"$n"\033[0m \033[40;32m"${filename[n]}"\033[0m"
}if (("$count" <= "0"));
then
echo "请下载部署包"
exit
elif (("$count" == "1"));
then
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
else
echo -e "\033[40;36m 请选择部署包:\033[0m"
read inNum
if (("$inNum" < "0")) || (("$inNum" >= "$count"))
then
echo "索引错误"
exit
else
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
fi
fi
fi#echo "解压部署包"
#echo $deploy
#tar -zxvf $deploy
#echo "解压部署包完成"inspect(){
if [ $argv != "PBox16.04" ];
then
cp -rf /mnt/profile /etc/
fi
if [ ! -d "/mnt/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/mnt/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ]; then cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/ ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2 fi sed -i '/source/d' /etc/init.d/rc.local sed -i '$a source /mnt/run.sh' /etc/init.d/rc.local #taosd &>/dev/null echo "历史数据库安装完成"
}
inspectPBox(){
if [ ! -d "/pbox/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/pbox/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ]; then cp -rf /pbox/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/ ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2 fi #taosd &>/dev/null echo "历史数据库安装完成"
}
echo "拷贝系统文件"
if [ $argv == "8401d" ];
then
cp -rf ./libstdc++.so.6 /usr/lib/arm-linux-gnueabihf/
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
fiif [ $argv == "ISG" ];
then
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
ln -sf /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/libstdc++.so.6if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /mnt/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fi
fiecho "拷贝系统文件完成"
echo -e "\033[40;36m 网口选择 单网(1)双网(2) \033[0m"
read input
#echo $input
if [ $input == "1" ];
then
sed -i 's/NetCardCount = "2"/NetCardCount = "1"/g' /mnt/FCloudComm/bin/pSL_Setting.xml
sed -i '/sleep 1/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/ifconfig eth1 192.168.20.101 netmask 255.255.255.0 up/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/route add default gw 192.168.20.1 dev eth1/d' /mnt/FCloudComm/tools/IPCfg
fi
echo "网口配置完成"#4G函数
echo -e "\033[40;36m 是否支持4G? 否(0)是(1) \033[0m"read -p "" number
if [ $number -eq 0 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
fiif [ $argv == "PBox" ]; then sed -i '/quectel-pppd.sh/d' /pbox/run.sh fi if [ $argv == "PBox16.04" ]; then sed -i '/quectel-pppd.sh/d' /mnt/run.sh fi
fi
if [ $number -eq 1 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
sed -i '/sleep 10/i\sh ./active4g.sh &' /mnt/run.sh
fiif [ $argv == "PBox" ]; then sed -i '/quectel-pppd.sh/d' /pbox/run.sh sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /pbox/run.sh fi if [ $argv == "PBox16.04" ]; then sed -i '/quectel-pppd.sh/d' /mnt/run.sh sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /mnt/run.sh fi
fi
if [ $number -ne 1 ] && [ $number -ne 0 ];
then
echo "输入错误"
fiecho "配置开机启动"
if [ $argv == "8401d" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rc.local
fiif [ $argv == "PBox16.04" ];
then
sed -i '1c #! /bin/bash' /etc/rc.local
fiif [ $argv == "ISG" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rocktech.sh
sed -i '$a source /mnt/run.sh' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rc.local
sed -i "114s:#::g" /etc/init.d/rocktech.sh
fiecho "配置开机启动完成"
echo "初始化本地ip地址"
sed -i 's/address 190.5.20.171/address 192.168.10.101/g' /etc/network/interfaces
sed -i 's/gateway 190.5.200.11/gateway 192.168.10.1/g' /etc/network/interfaces
sed -i 's/address 192.168.1.100/address 192.168.20.101/g' /etc/network/interfaces
sed -i 's/gateway 192.168.1.1/gateway 192.168.20.1/g' /etc/network/interfaces
echo "初始化本地ip地址结束"echo "配置历史数据库"
#td库ISG网关配置
td(){
cd /mnt/TDengine-server-2.0.10.0/
./install.sh &>/dev/null
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
sed -i 's/# fqdn/fqdn/g' /etc/taos/taos.cfg
sed -i 's/hostname/localhost/g' /etc/taos/taos.cfg
}#PBox网关配置
PB(){
if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /pbox/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fised -i '1c #! /bin/bash' /etc/init.d/rc.local cd /pbox/TDengine-server-2.0.10.0 ./install.sh &>/dev/null sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg sed -i 's/# logDir/ logDir/g' /etc/taos/taos.cfg sed -i 's/# dataDir/ dataDir/g' /etc/taos/taos.cfg sed -i 's#/var/log/taos#/pbox/log#g' /etc/taos/taos.cfg sed -i 's#/var/lib/taos#/pbox/lib#g' /etc/taos/taos.cfg sed -i '/run.sh/d' /etc/rc5.d/S99rmnologin.sh sed -i '$a source /pbox/run.sh' /etc/rc5.d/S99rmnologin.sh
}
power(){
source /mnt/FCloudComm/tools/setEnv.sh
if [ -d "/mnt/config" ];then
#echo "文件夹存在"if [ -f "/mnt/config/hardwareinfo.HID" ];then #echo "文件存在" cp -rf /mnt/config/hardwareinfo.HID /mnt/FCloudComm else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /mnt/FCloudComm/bin/getID fi if [ -f "/mnt/config/"*".lic" ];then #echo "文件存在" cp -rf /mnt/config/*.lic /mnt/FCloudComm/bin else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /mnt/FCloudComm/bin/getID fi else #echo "文件夹不存在" echo "配置完成 请放入HID 和 授权文件" /mnt/FCloudComm/bin/getID fi #echo "配置完成 请放入HID 和 授权文件" #/mnt/FCloudComm/bin/getID
}
powerPBox(){
source /pbox/FCloudComm/tools/setEnv.sh
if [ -d "/pbox/config" ];then
#echo "文件夹存在"if [ -f "/pbox/config/hardwareinfo.HID" ];then #echo "文件存在" cp -rf /pbox/config/hardwareinfo.HID /pbox/FCloudComm else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /pbox/FCloudComm/bin/getID fi if [ -f "/pbox/config/"*".lic" ];then #echo "文件存在" cp -rf /pbox/config/*.lic /pbox/FCloudComm/bin else #echo "文件不存在" echo "配置完成 请放入HID 和 授权文件" /pbox/FCloudComm/bin/getID fi else #echo "文件夹不存在" echo "配置完成 请放入HID 和 授权文件" /pbox/FCloudComm/bin/getID fi #echo "配置完成 请放入HID 和 授权文件" #/pbox/FCloudComm/bin/getID
}
case "$1" in
8401d)
cd /mnt/TDengine-server-2.0.10.0
./install.sh &>/dev/null
sed -i 's#/third/log#log#g' /etc/taos/taos.cfg
sed -i 's#/third/data#data#g' /etc/taos/taos.cfg
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
inspect
power
;;
8316)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 GEA-8316-DLK" ];
then
i="1"
fi
done < /etc/hostsif [ "$i" != "1" ]; then sed -i '$a\127.0.0.1 GEA-8316-DLK' /etc/hosts fi cd /mnt/TDengine-server-2.0.10.0 ./install.sh &>/dev/null sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg inspect power ;; ISG) i="0" while read path do if [ "$path" == "127.0.0.1 localhost" ]; then i="1" fi done < /etc/hosts if [ "$i" != "1" ]; then echo "127.0.0.1 localhost"> /etc/hosts fi td inspect power ;; PBox) i="0" while read path do if [ "$path" == "127.0.0.1 imx6ull14x14evk" ]; then i="1" fi done < /etc/hosts if [ "$i" != "1" ]; then echo "127.0.0.1 imx6ull14x14evk"> /etc/hosts fi PB inspectPBox powerPBox ;; PBox16.04) pkexec chown root:root /etc/sudoers /etc/sudoers.d -R td inspect power sed -i '/source/d' /etc/init.d/rc.local sed -i '/source/d' /etc/rc.local sed -i '/sleep 1/isource /mnt/run.sh' /etc/rc.local ;;
esac
-
for culture 说:
@ChatGPT 用python重写如下脚本,输出完整代码并给出注释
#!/bin/bash
argv=$1
#deploy=$1
count=0
filename=()
isTar=1
if [ $isTar == "1" ]
thenpath=
cd $(dirname $0);pwd -P
#echo the current path is:$path
for i inls
do
filegz="tar.gz"
if [[ $i == $filegz ]]
then
#echo $i
filename[count]=$i
count=expr $count + 1
fi
done#echo $count
#echo ${filename[@]}
for((n=0;n echo -e "\033[40;35m"$n"\033[0m \033[40;32m"${filename[n]}"\033[0m"
}if (("$count" then
echo "请下载部署包"
exit
elif (("$count" == "1"));
then
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
else
echo -e "\033[40;36m 请选择部署包:\033[0m"
read inNum
if (("$inNum" = "$count"))
then
echo "索引错误"
exit
else
if [ $argv == "PBox" ];
then
tar zxvf ${filename[0]} -C /pbox
else
tar zxvf ${filename[0]} -C /mnt
fi
fi
fi
fi#echo "解压部署包"
#echo $deploy
#tar -zxvf $deploy
#echo "解压部署包完成"inspect(){
if [ $argv != "PBox16.04" ];
then
cp -rf /mnt/profile /etc/
fi
if [ ! -d "/mnt/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/mnt/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ];
then
cp -rf /mnt/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2
fised -i '/source/d' /etc/init.d/rc.local
sed -i '$a source /mnt/run.sh' /etc/init.d/rc.local#taosd &>/dev/null
echo "历史数据库安装完成"}
inspectPBox(){
if [ ! -d "/pbox/FCloudComm" ]
then
echo "1"
exit
fi
if [ ! -f "/pbox/run.sh" ]
then
echo "2"
exit
fiif [ ! -f "/usr/lib/libiconv.so.2.6.1" ];
then
cp -rf /pbox/FCloudComm/bin/libiconv.so.2.6.1 /usr/lib/
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so
ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2
fi#taosd &>/dev/null
echo "历史数据库安装完成"}
echo "拷贝系统文件"
if [ $argv == "8401d" ];
then
cp -rf ./libstdc++.so.6 /usr/lib/arm-linux-gnueabihf/
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
fiif [ $argv == "ISG" ];
then
cp -rf ./libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/
ln -sf /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.21 /usr/lib/arm-linux-gnueabihf/libstdc++.so.6if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /mnt/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fi
fiecho "拷贝系统文件完成"
echo -e "\033[40;36m 网口选择 单网(1)双网(2) \033[0m"
read input
#echo $input
if [ $input == "1" ];
then
sed -i 's/NetCardCount = "2"/NetCardCount = "1"/g' /mnt/FCloudComm/bin/pSL_Setting.xml
sed -i '/sleep 1/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/ifconfig eth1 192.168.20.101 netmask 255.255.255.0 up/d' /mnt/FCloudComm/tools/IPCfg
sed -i '/route add default gw 192.168.20.1 dev eth1/d' /mnt/FCloudComm/tools/IPCfg
fi
echo "网口配置完成"#4G函数
echo -e "\033[40;36m 是否支持4G? 否(0)是(1) \033[0m"read -p "" number
if [ $number -eq 0 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
fiif [ $argv == "PBox" ];
then
sed -i '/quectel-pppd.sh/d' /pbox/run.sh
fiif [ $argv == "PBox16.04" ];
then
sed -i '/quectel-pppd.sh/d' /mnt/run.sh
fi
fiif [ $number -eq 1 ];
then
if [ $argv == "8401d" ];
then
sed -i '/active4g.sh/d' /mnt/run.sh
sed -i '/sleep 10/i\sh ./active4g.sh &' /mnt/run.sh
fiif [ $argv == "PBox" ];
then
sed -i '/quectel-pppd.sh/d' /pbox/run.sh
sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /pbox/run.sh
fiif [ $argv == "PBox16.04" ];
then
sed -i '/quectel-pppd.sh/d' /mnt/run.sh
sed -i '/sleep 10/i\sh ./quectel-pppd.sh &' /mnt/run.sh
fi
fiif [ $number -ne 1 ] && [ $number -ne 0 ];
then
echo "输入错误"
fiecho "配置开机启动"
if [ $argv == "8401d" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rc.local
fiif [ $argv == "PBox16.04" ];
then
sed -i '1c #! /bin/bash' /etc/rc.local
fiif [ $argv == "ISG" ];
then
sed -i '1c #! /bin/bash' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rocktech.sh
sed -i '$a source /mnt/run.sh' /etc/init.d/rocktech.sh
sed -i '/source/d' /etc/init.d/rc.local
sed -i "114s:#::g" /etc/init.d/rocktech.sh
fiecho "配置开机启动完成"
echo "初始化本地ip地址"
sed -i 's/address 190.5.20.171/address 192.168.10.101/g' /etc/network/interfaces
sed -i 's/gateway 190.5.200.11/gateway 192.168.10.1/g' /etc/network/interfaces
sed -i 's/address 192.168.1.100/address 192.168.20.101/g' /etc/network/interfaces
sed -i 's/gateway 192.168.1.1/gateway 192.168.20.1/g' /etc/network/interfaces
echo "初始化本地ip地址结束"echo "配置历史数据库"
#td库ISG网关配置
td(){
cd /mnt/TDengine-server-2.0.10.0/
./install.sh &>/dev/null
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
sed -i 's/# fqdn/fqdn/g' /etc/taos/taos.cfg
sed -i 's/hostname/localhost/g' /etc/taos/taos.cfg
}#PBox网关配置
PB(){
if [ ! -f "/usr/lib/libatomic.so.1.0.0" ];
then
cp -rf /pbox/FCloudComm/bin/libatomic.so.1.0.0 /usr/lib/
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so.1
ln -sf /usr/lib/libatomic.so.1.0.0 /usr/lib/libatomic.so
fised -i '1c #! /bin/bash' /etc/init.d/rc.local
cd /pbox/TDengine-server-2.0.10.0
./install.sh &>/dev/null
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
sed -i 's/# logDir/ logDir/g' /etc/taos/taos.cfg
sed -i 's/# dataDir/ dataDir/g' /etc/taos/taos.cfg
sed -i 's#/var/log/taos#/pbox/log#g' /etc/taos/taos.cfg
sed -i 's#/var/lib/taos#/pbox/lib#g' /etc/taos/taos.cfgsed -i '/run.sh/d' /etc/rc5.d/S99rmnologin.sh
sed -i '$a source /pbox/run.sh' /etc/rc5.d/S99rmnologin.sh
}power(){
source /mnt/FCloudComm/tools/setEnv.sh
if [ -d "/mnt/config" ];then
#echo "文件夹存在"if [ -f "/mnt/config/hardwareinfo.HID" ];then
#echo "文件存在"
cp -rf /mnt/config/hardwareinfo.HID /mnt/FCloudComm
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/mnt/FCloudComm/bin/getID
fiif [ -f "/mnt/config/"".lic" ];then
#echo "文件存在"
cp -rf /mnt/config/.lic /mnt/FCloudComm/bin
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/mnt/FCloudComm/bin/getID
fielse
#echo "文件夹不存在"
echo "配置完成 请放入HID 和 授权文件"
/mnt/FCloudComm/bin/getID
fi
#echo "配置完成 请放入HID 和 授权文件"
#/mnt/FCloudComm/bin/getID
}powerPBox(){
source /pbox/FCloudComm/tools/setEnv.sh
if [ -d "/pbox/config" ];then
#echo "文件夹存在"if [ -f "/pbox/config/hardwareinfo.HID" ];then
#echo "文件存在"
cp -rf /pbox/config/hardwareinfo.HID /pbox/FCloudComm
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/pbox/FCloudComm/bin/getID
fiif [ -f "/pbox/config/"".lic" ];then
#echo "文件存在"
cp -rf /pbox/config/.lic /pbox/FCloudComm/bin
else
#echo "文件不存在"
echo "配置完成 请放入HID 和 授权文件"
/pbox/FCloudComm/bin/getID
fielse
#echo "文件夹不存在"
echo "配置完成 请放入HID 和 授权文件"
/pbox/FCloudComm/bin/getID
fi
#echo "配置完成 请放入HID 和 授权文件"
#/pbox/FCloudComm/bin/getID
}case "$1" in
8401d)
cd /mnt/TDengine-server-2.0.10.0
./install.sh &>/dev/null
sed -i 's#/third/log#log#g' /etc/taos/taos.cfg
sed -i 's#/third/data#data#g' /etc/taos/taos.cfg
sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg
inspect
power
;;
8316)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 GEA-8316-DLK" ];
then
i="1"
fi
done
if [ "$i" != "1" ];
then
sed -i '$a\127.0.0.1 GEA-8316-DLK' /etc/hosts
ficd /mnt/TDengine-server-2.0.10.0 ./install.sh &>/dev/null sed -i 's/firstEp/#firstEp/g' /etc/taos/taos.cfg inspect power ;;
ISG)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 localhost" ];
then
i="1"
fi
done
if [ "$i" != "1" ];
then
echo "127.0.0.1 localhost"> /etc/hosts
fitd inspect power ;;
PBox)
i="0"
while read path
do
if [ "$path" == "127.0.0.1 imx6ull14x14evk" ];
then
i="1"
fi
done
if [ "$i" != "1" ];
then
echo "127.0.0.1 imx6ull14x14evk"> /etc/hosts
fi
PB
inspectPBox
powerPBox
;;
PBox16.04)
pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
td
inspect
power
sed -i '/source/d' /etc/init.d/rc.local
sed -i '/source/d' /etc/rc.local
sed -i '/sleep 1/isource /mnt/run.sh' /etc/rc.local
;;
esac以下是Python版的代码和注释:
#!/usr/bin/python3 import os import shutil import subprocess def inspect(): # 用于安装历史数据库和权限文件等等操作 if deploy != "PBox16.04": # 复制profile文件 shutil.copy("/mnt/profile", "/etc/") # 判断历史数据库文件夹是否存在 # 若不存在,则返回错误信息 if not os.path.exists("/mnt/FCloudComm"): print("1") return # 判断run.sh是否存在 # 若不存在,则返回错误信息 elif not os.path.exists("/mnt/run.sh"): print("2") return # 若libiconv.so.2.6.1文件不存在 # 则将该文件复制到/usr/lib/下,并建立软链接 if not os.path.exists("/usr/lib/libiconv.so.2.6.1"): shutil.copy("/mnt/FCloudComm/bin/libiconv.so.2.6.1", "/usr/lib/") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so") os.system("ln -sf /usr/lib/libiconv.so.2.6.1 /usr/lib/libiconv.so.2") # 将run.sh脚本配置到开机启动项中 subprocess.call("sed -i '/source/d' /etc/init.d/rc.local", shell=True) subprocess.call("sed -i '$a source /mnt/run.sh' /etc/init.d/rc.local", shell=True) # 执行完成后,输出提示信息 print("历史数据库安装完成") # 定义函数,用于安装历史数据库和权限文件等等操作(针对PBox版本) def inspectPBox(): # 判断历史数据库文件夹是否存在 # 若不存在,则返回错误信息 if not os.path.exists("/pbox/FCloudComm"): print("1") return # 判断run.sh是否存在 # 若不存在,则返回错误信息 elif not os.path.exists("/pbox/run.sh"): print("2") return # 若libiconv.so.2.6.1文件不存在 # 则将该文件复制到/usr/lib/下,并建立软链接 if not os.path.exists("/usr/lib/libiconv.so.2.6.1"): shutil.copy("/pbox/FCloudComm/bin/libiconv.so.2.6.1", "/usr/lib/") os.system("ln -sf