Setupbox-Server/monitor/setup/setup.sh
2019-10-14 10:24:24 +07:00

111 lines
2.9 KiB
Bash

#!/bin/bash
#***************set time****************************
echo "Set timezon"
unlink /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime
#*************cap quyen****************************
echo "cap quyen"
chown root:root /etc/sudoers
export DISPLAY =:0
sudo chmod +x /root/monitor/cache/clearcache.sh
sudo chmod +x /root/monitor/check/Check_engine
sudo chmod +x /root/monitor/launcher/S905X_BI
sudo chmod +x /root/monitor/CMS/install.sh
sudo chmod +x /root/monitor/CMS/run_cms.sh
sudo chmod +x /root/monitor/setup/run_CMS.sh install_S905X_BI.sh
sudo chmod +x /root/monitor/setup/key.sh
#******************CMS*************************
echo "install CMS"
sudo /root/monitor/CMS/install.sh
# ******************Autossh******************
#
echo "install auto ssh"
sudo apt-get install -y autossh
#*****************Screen********************
echo "install screen"
sudo apt-get install -y screen
chmod 777 /var/run/screen
#****************run_cms rc.local*************
echo "setup rc.local"
echo > /etc/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
fi
echo "Begin rc.local. Time restart: $time_begin" >> /root/monitor/log/rc_local.log
sudo /root/monitor/CMS/run_cms.sh
exit 0' > /etc/rc.local
#
echo "network"
echo -e "#IP#\n\n###" >> /etc/network/interfaces
#
#*************setup service S905X_BI***************
echo "setup autorun S905X_BI"
cd /etc/systemd/system/
echo "[Unit]
Description=S905X_BI demo service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/usr/bin/env /root/monitor/launcher/S905X_BI
[Install]
WantedBy=multi-user.target" >> S905X_BI.service
sudo chmod 755 S905X_BI.service
sudo systemctl start S905X_BI
sudo systemctl enable S905X_BI
#
#*************setup Opencv***************
echo "install Opencv"
cd /root/monitor/setup
tar -xvzf install_box-master.tar.gz
sudo chmod +x /root/monitor/setup/install_box/install_box.sh
sudo /root/monitor/setup/install_box/install_box.sh
#
#*************Copy key ssh***************
echo "copy key"
sudo /root/monitor/setup/key.sh
#
#*************setup schedule crontab**********
echo "setup schedule crontab"
echo "33 3 * * * sudo /root/monitor/cache/clearcache.sh" >> /var/spool/cron/crontabs/root
#
#*************setup autologin***************
echo "setup autologin"
os_version=$(cat /etc/issue |grep "Ubuntu 18.04")
if [ -n "$os_version" ]; then
sudo apt-get install -y rng-tools
cd /etc/lightdm/lightdm.conf.d
echo "autologin-user=root
autologin-user-timeout=0
" >> 11-armbian.conf
fi
#
sudo apt-get -y update
#
reboot