Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/Cat5TV/nems-scripts

  • Loading branch information...
NEMS Linux
NEMS Linux committed Sep 10, 2019
2 parents 792485a + c5c85b6 commit c200e5765f6a311ccc41c2f4196ebbf1a5587116
Showing with 66 additions and 17 deletions.
  1. +2 −0 bootscreen.sh
  2. +25 −11 fixes.sh
  3. +9 −2 info.sh
  4. +18 −2 info2.sh
  5. +12 −2 init.sh
@@ -4,6 +4,8 @@
ver=$(/usr/local/bin/nems-info nemsver)
host=$(/bin/hostname)

# Should set screen resolution on each board
# See: https://linuxhint.com/set_screen_resolution_linux_kernel_boot/

# Don't allow TTY to go blank
/usr/bin/setterm -blank 0
@@ -193,8 +193,10 @@ check process 9590 with pidfile /run/9590.pid
fi

# Stop TTY1 from blanking since keyboard is likely not connected
if ! grep -q "NEMS00000" /etc/rc.local; then
/root/nems/nems-admin/build/011-tty
if [[ -e /etc/rc.local ]]; then
if ! grep -q "NEMS00000" /etc/rc.local; then
/root/nems/nems-admin/build/011-tty
fi
fi

# Remove Izzy's repository (at least temporarily).
@@ -308,6 +310,11 @@ fi

if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.5'")}') )); then

# Setup Vendor capabilities
if [[ ! -e /boot/vendor ]]; then
mkdir /boot/vendor
fi

# Add custom_check_mem
if [[ ! -e /usr/lib/nagios/plugins/custom_check_mem ]]; then
cp /root/nems/nems-migrator/data/1.5/nagios/plugins/custom_check_mem /usr/lib/nagios/plugins
@@ -333,7 +340,7 @@ if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.5'")}') )); then
fi

# Upgrade Telegram
telegramver=1.5.1 # Current version of Temper script
telegramver=1.5.6 # Current version of Telegram script
if ! grep -q "VERSION $telegramver" /usr/lib/nagios/plugins/notify-by-telegram.lua; then
cp -f /root/nems/nems-migrator/data/1.5/nagios/plugins/notify-by-telegram.lua /usr/lib/nagios/plugins/notify-by-telegram.lua
fi
@@ -453,14 +460,18 @@ if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.5'")}') )); then
fi

# Move bootscreen to TTY7 and disable TTY1
if [[ -e /etc/rc.local ]]; then
if ! grep -q "NEMS00001" /etc/rc.local; then
/root/nems/nems-admin/build/010-tty
fi
fi

# Don't output kernel messages -- such as firewall blocks -- to TTY
if [[ -e /etc/rc.local ]]; then
if ! grep -q "NEMS00002" /etc/rc.local; then
/root/nems/nems-admin/build/012-tty
fi
fi

# Allow unauthenticated SMTP
if ! grep -q "NEMS00002" /usr/local/nagios/libexec/nems_sendmail_host; then
@@ -487,10 +498,12 @@ if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.5'")}') )); then
fi

# enable rc.local service if not enabled (ie., Rock64)
if [[ -e /etc/rc.local ]]; then
if [[ ! -e /etc/systemd/system/rc-local.service ]]; then
/root/nems/nems-admin/build/009-rc_local
/root/nems/nems-admin/build/999-cleanup
fi
fi

# Patch check_rpi_temperature to include error handling for when the thermal sensor doesn't exist (ie., VM)
if ! grep -q "PATCH-000006" /var/log/nems/patches.log; then
@@ -746,15 +759,16 @@ fi
fi

# Load ZRAM Swap at boot
if ! grep -q "NEMS0000" /etc/rc.local; then
# fix comment so it doesn't get replaced
/bin/sed -i -- 's,"exit 0",exit with errorcode 0,g' /etc/rc.local
# add to boot process
/bin/sed -i -- 's,exit 0,# Load Swap into ZRAM NEMS0000\n/usr/local/share/nems/nems-scripts/zram.sh > /dev/null 2>\&1\n\nexit 0,g' /etc/rc.local
# run it now
/usr/local/share/nems/nems-scripts/zram.sh # Do it now
if [[ -e /etc/rc.local ]]; then
if ! grep -q "NEMS0000" /etc/rc.local; then
# fix comment so it doesn't get replaced
/bin/sed -i -- 's,"exit 0",exit with errorcode 0,g' /etc/rc.local
# add to boot process
/bin/sed -i -- 's,exit 0,# Load Swap into ZRAM NEMS0000\n/usr/local/share/nems/nems-scripts/zram.sh > /dev/null 2>\&1\n\nexit 0,g' /etc/rc.local
# run it now
/usr/local/share/nems/nems-scripts/zram.sh # Do it now
fi
fi

if [ $(dpkg-query -W -f='${Status}' memtester 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get -y install memtester
fi
11 info.sh
@@ -196,11 +196,11 @@ elif [[ $COMMAND == "rootfulldev" ]]; then
/bin/mount | /bin/sed -n 's|^/dev/\(.*\) on / .*|\1|p'

elif [[ $COMMAND == "rootdev" ]]; then
# output json response of detected wifi networks
# Root device name of the / filesystem (eg., sda or mmcblk0)
/usr/local/share/nems/nems-scripts/info2.sh 8

elif [[ $COMMAND == "rootpart" ]]; then
# output json response of detected wifi networks
# Root partition number of the / filesystem (eg., 1)
/usr/local/share/nems/nems-scripts/info2.sh 9

elif [[ $COMMAND == "wifi" ]]; then
@@ -320,6 +320,13 @@ grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}'
elif [[ $COMMAND == "temperature" ]]; then
/usr/local/share/nems/nems-scripts/info2.sh 1

elif [[ $COMMAND == "frequency" ]]; then
if [[ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ]]; then
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
else
echo 0
fi

elif [[ $COMMAND == "nemsbranch" ]]; then
/usr/local/share/nems/nems-scripts/info2.sh 2

@@ -112,9 +112,17 @@ switch($argv[1]) {
break;
case 8: // root device
// $fulldev=shell_exec("df /root | awk '/^\/dev/ {print $1}'");
$fulldev=trim(shell_exec("/usr/local/bin/nems-info rootfulldev"));
$tmp = explode('p',$fulldev);
if (!is_array($tmp) || !isset($tmp[1])) {
// Check if is SCSI
preg_match_all('!\d+!', $fulldev, $numbers);
if (is_array($numbers) && isset($numbers[0][0])) {
$tmp = array();
$tmp[0] = preg_replace('/' . $numbers[0][0] . '$/', '', $fulldev);
$tmp[1] = $numbers[0][0];
}
}
if (is_array($tmp)) {
end($tmp);
$lastkey = key($tmp);
@@ -130,9 +138,17 @@ switch($argv[1]) {
break;
case 9: // root partition on root device
// $fulldev=shell_exec("df /root | awk '/^\/dev/ {print $1}'");
$fulldev=trim(shell_exec("/usr/local/bin/nems-info rootfulldev"));
$tmp = explode('p',$fulldev);
if (!is_array($tmp) || !isset($tmp[1])) {
// Check if is SCSI
preg_match_all('!\d+!', $fulldev, $numbers);
if (is_array($numbers) && isset($numbers[0][0])) {
$tmp = array();
$tmp[0] = preg_replace('/' . $numbers[0][0] . '$/', '', $fulldev);
$tmp[1] = $numbers[0][0];
}
}
if (is_array($tmp)) {
end($tmp);
$partkey = key($tmp);
14 init.sh
@@ -262,7 +262,12 @@ fi
# Replace the database with Sample database
systemctl stop mysql
# Force kill MySQL (in case safe mode prevents shutdown, as is the case on Docker)
sleep 3 && kill -9 $(pidof mysqld)
sleep 3
mysqldpid=$(pidof mysqld)
if [[ $mysqldpid != "" ]]; then
kill -9 $mysqldpid
sleep 1
fi
rm -rf /var/lib/mysql/
if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.5'")}') )); then
cp -R /root/nems/nems-migrator/data/1.5/mysql/NEMS-Sample /var/lib
@@ -274,7 +279,12 @@ fi
mv /var/lib/NEMS-Sample /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
# Force kill MySQL (in case safe mode prevents shutdown, as is the case on Docker)
sleep 3 && kill -9 $(pidof mysqld) && sleep 1
sleep 3
mysqldpid=$(pidof mysqld)
if [[ $mysqldpid != "" ]]; then
kill -9 $mysqldpid
sleep 1
fi
systemctl start mysql

# Replace the Nagios cgi.cfg file with the sample and add username

0 comments on commit c200e57

Please sign in to comment.
You can’t perform that action at this time.