diff --git a/monitor/setup/permission.sh b/monitor/setup/permission.sh index 9d59a7c..ce7477f 100644 --- a/monitor/setup/permission.sh +++ b/monitor/setup/permission.sh @@ -8,9 +8,11 @@ sudo chmod +x /root/monitor/cache/restart_service.sh sudo chmod +x /root/monitor/check/Check_engine sudo chmod +x /root/monitor/launcher/S905X_BI sudo chmod +x /root/monitor/setup/install_S905X_BI.sh -sudo chmod +x /root/monitor/setup/capture.sh sudo chmod +x /root/monitor/setup/key.sh sudo chmod +x /root/monitor/setup/serverlite.sh sudo chmod +x /root/monitor/setup/datetime -sudo chmod +x /root/monitor/setup/update_serverlite.sh +sudo chmod +x /root/monitor/setup/ver_cloud.sh +sudo chmod +x /root/monitor/setup/ver_pro.sh +sudo chmod +x /root/monitor/setup/update_version_engine.sh + exit 0 \ No newline at end of file diff --git a/monitor/setup/update_engine.sh b/monitor/setup/update_engine.sh new file mode 100644 index 0000000..622fc64 --- /dev/null +++ b/monitor/setup/update_engine.sh @@ -0,0 +1,6 @@ +#!/bin/bash +if [ "$1" = pro ] +then /root/monitor/setup/ver_pro.sh +else /root/monitor/setup/ver_cloud.sh +fi +exit 0 \ No newline at end of file diff --git a/monitor/setup/ver_cloud.sh b/monitor/setup/ver_cloud.sh new file mode 100644 index 0000000..259f7c4 --- /dev/null +++ b/monitor/setup/ver_cloud.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# xoa run tmux server lite trong rc.local +echo "setup rc.local" +echo '#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + + +#/boot/fan.sh & + +if [ ! -d /var/run/sshd ]; then + mkdir /var/run/sshd + chmod 0755 /var/run/sshd + systemctl restart ssh +time_begin=$(date) +echo "Begin rc.local. Time restart: $time_begin" >> /root/monitor/log/rc_local.log +echo "nameserver 8.8.8.8" > /etc/resolv.conf +{ +printf 'power on\n' +sleep 2 +printf 'discoverable on\n' +sleep 2 +printf 'quit\n' +}|bluetoothctl + +pulseaudio --start +bt-agent -c NoInputNoOutput "* *" + +exit 0' > /etc/rc.local +# Cai dat PM2 khong khoi dong cung ubuntu +pm2 unstartup +cd /root/monitor/setup +rm ecosystem.config.js +# Cai dat engine +systemctl stop S905X_BI +# Xoa engine.json +cd /root/monitor/setup/ +rm engine.json +# Xoa engine +cd /root/monitor/engine +rm -rf * +# Tai engine +systemctl start S905X_BI + +exit 0 diff --git a/monitor/setup/ver_pro.sh b/monitor/setup/ver_pro.sh new file mode 100644 index 0000000..91d01b2 --- /dev/null +++ b/monitor/setup/ver_pro.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# xoa run tmux server lite trong rc.local +echo "setup rc.local" +echo '#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + + +#/boot/fan.sh & + +if [ ! -d /var/run/sshd ]; then + mkdir /var/run/sshd + chmod 0755 /var/run/sshd + systemctl restart ssh +time_begin=$(date) +echo "Begin rc.local. Time restart: $time_begin" >> /root/monitor/log/rc_local.log +echo "nameserver 8.8.8.8" > /etc/resolv.conf +{ +printf 'power on\n' +sleep 2 +printf 'discoverable on\n' +sleep 2 +printf 'quit\n' +}|bluetoothctl + +pulseaudio --start +bt-agent -c NoInputNoOutput "* *" +# tmux new -d -s server_js 'node /root/BiFace_Server_Config_API/server.js' +exit 0' > /etc/rc.local +# Cai dat PM2 run Server lite +sudo apt install npm +npm install pm2 -g +pm2 install pm2-logrotate + +cd /root/monitor/setup/ +pm2 ecosystem +echo " +module.exports = { + apps : [ + { + name: 'NodeClient', + cwd: '/root/monitor/setup/node_client', + script: 'client.js', + args: '', + interpreter: 'node', + restart_delay: 1000, + cron_restart: '0 0 * * *', + watch: false, + time: true + } +] +}; +" > ecosystem.config.js +# Khởi chạy pm2 vs cấu hình vừa sửa +pm2 reload ecosystem.config.js + +# Cài đặt pm2 khởi động cùng Win/Ubuntu +pm2 startup +# Copy-paste và chạy dòng script hiện trên màn hình +pm2 save +# Cai dat engine +systemctl stop S905X_BI +# Xoa engine.json +cd /root/monitor/setup/ +rm engine.json +# Xoa engine +cd /root/monitor/engine +rm -rf * +# Tai engine +systemctl start S905X_BI + +exit 0