Files
webgui/etc/rc.d/rc.local
T
Tom Mortensen f9ec00b488 repo reorg
2023-06-02 12:49:33 -07:00

165 lines
5.5 KiB
Bash
Executable File

#!/bin/bash
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
# irqbalance daemon distributes interrupts over processors and cores
#if [ -x /usr/sbin/irqbalance ]; then
# /usr/sbin/irqbalance
#fi
# reclaim 1.6M of microcode files that are no longer needed
rm -rf /kernel
# rc.samba now executable
chmod +x /etc/rc.d/rc.samba
# Start WireGuard
if [ -x /etc/rc.d/rc.wireguard ]; then
/etc/rc.d/rc.wireguard start
fi
# Start mcelog
if [ -x /etc/rc.d/rc.mcelog ]; then
/etc/rc.d/rc.mcelog start
fi
# For Docker: mark submounts under /mnt "shared"
/sbin/mount --bind --make-rshared /mnt /mnt
# and grant access to graphics device nodes
[[ -d /dev/dri ]] && chmod -R 777 /dev/dri
# Ensure required config directories exist
# these will all have permissions 0700
CONFIG="/boot/config"
mkdir -p $CONFIG/modprobe.d
mkdir -p $CONFIG/plugins/dockerMan
mkdir -p $CONFIG/plugins/dynamix/users
mkdir -p $CONFIG/plugins-error/
mkdir -p $CONFIG/pools
mkdir -p $CONFIG/shares
mkdir -p $CONFIG/ssh/root
mkdir -p $CONFIG/ssl/certs
# upgrade network configuration (if needed) and (re)generates our welcome text
if [[ -x /usr/local/sbin/create_network_ini ]]; then
/usr/local/sbin/create_network_ini init >/dev/null 2>&1 &
fi
# Needed by dynamix
# copy monitor.ini file
if [[ -s $CONFIG/plugins/dynamix/monitor.ini ]]; then
cp $CONFIG/plugins/dynamix/monitor.ini /var/local/emhttp
chmod -x /var/local/emhttp/monitor.ini
fi
# initialize notifications
/usr/local/emhttp/webGui/scripts/notify smtp-init
/usr/local/emhttp/webGui/scripts/notify cron-init
# start nchan monitoring -> stop all running nchan processes when no subscribers are connected
if [[ -x /usr/local/sbin/monitor_nchan ]]; then
/usr/local/sbin/monitor_nchan
fi
# First boot following unRAID Server OS update: delete plugin file
rm -f /boot/plugins/unRAIDServer.plg
rm -f $CONFIG/plugins/unRAIDServer.plg
# These plugins are now integrated in the OS or obsolete and may interfere
Obsolete="vfio.pci dynamix.wireguard dynamix.ssd.trim"
for Plugin in $Obsolete ; do
if [[ -e $CONFIG/plugins/$Plugin.plg ]]; then
logger "moving obsolete plugin $Plugin.plg to $CONFIG/plugins-error"
# preserve ssd-trim config
if [[ $Plugin = "dynamix.ssd.trim" ]]; then
if [[ -e $CONFIG/plugins/$Plugin/$Plugin.cfg ]]; then
echo "[ssd]" >> $CONFIG/plugins/dynamix/dynamix.cfg
cat $CONFIG/plugins/$Plugin/$Plugin.cfg >> $CONFIG/plugins/dynamix/dynamix.cfg
fi
if [[ -e $CONFIG/plugins/$Plugin/ssd-trim.cron ]]; then
mv $CONFIG/plugins/$Plugin/ssd-trim.cron $CONFIG/plugins/dynamix/ssd-trim.cron
fi
fi
mv $CONFIG/plugins/$Plugin.plg $CONFIG/plugins-error/
rm -rf $CONFIG/plugins/$Plugin
fi
done
# uninstall obsolete plugins
#
# these plugins with these versions or older are incompatible with this version of Unraid
# if found, they will be moved from ${CONFIG}/plugins to ${CONFIG}/plugins-error
# in theory, newer versions will be ok
#
function obsplg {
Plugin=$1
BadVer=$2
if [[ -e "$CONFIG/plugins/$Plugin.plg" ]]; then
Ver=$(/usr/local/sbin/plugin version "$CONFIG/plugins/$Plugin.plg")
# assumes all version strings are of form YYYY.MM.DD[.letter]
if [[ "$Ver" < "$BadVer" || "$Ver" == "$BadVer" ]]; then
logger "moving obsolete plugin $Plugin.plg version $Ver to $CONFIG/plugins-error"
/usr/local/emhttp/webGui/scripts/notify -e "Plugin Removed" -s "$Plugin" -d "Plugin '$Plugin' version '$Ver' was removed as it is incompatible with this version of Unraid OS" -m "A replacement *may* be available in Community Apps" -i "alert" -l "/Plugins"
mv "$CONFIG/plugins/$Plugin.plg" "$CONFIG/plugins-error/"
# notify needs a delay between notifications
sleep 1
fi
fi
}
# Disk Location by olehj, breaks the dashboard
obsplg "disklocation-master" "2022.06.18"
# Plex Streams by dorgan, breaks the dashboard
obsplg "plexstreams" "2022.08.31"
# Corsair PSU Statistics by Fma965, breaks the dashboard
obsplg "corsairpsu" "2021.10.05"
# GPU Statistics by b3rs3rk, breaks the dashboard
obsplg "gpustat" "2022.11.30a"
# IPMI Tools by dmacias72, breaks the dashboard
obsplg "ipmi" "2021.01.08"
# NUT - Network UPS Tools by dmacias72, breaks the dashboard
obsplg "nut" "2022.03.20"
# Nerd Tools by dmacias72
obsplg "NerdPack" "2021.08.11"
# UPnP Monitor by ljm42, not PHP 8 compatible
obsplg "upnp-monitor" "2020.01.04c"
# ZFS-Companion Monitor by campusantu, breaks the dashboard
obsplg "ZFS-companion" "2021.08.24"
# If "unraidsafemode" indicated, skip installing extra packages and plugins
if [[ -f /boot/unraidsafemode ]] || grep -wq unraidsafemode /proc/cmdline ; then
logger "unRAID Safe Mode (unraidsafemode) has been set"
else
# Install any extra packages
if [ -d /boot/extra ]; then
logger "Installing /boot/extra packages"
( cd /boot/extra ; find -maxdepth 1 -type f -exec upgradepkg --install-new {} \; )
fi
# Install plugins
logger "Installing plugins"
shopt -s nullglob
for Plugin in $CONFIG/plugins/*.plg ; do
/usr/local/sbin/plugin install $Plugin | logger
done
shopt -u nullglob
fi
# Install languages
logger "Installing language packs"
shopt -s nullglob
for Language in $CONFIG/plugins/lang-*.xml ; do
/usr/local/sbin/language install $Language | logger
done
shopt -u nullglob
# Invoke the 'go' script
if [ -f $CONFIG/go ]; then
logger "Starting go script"
fromdos <$CONFIG/go >/var/tmp/go
chmod +x /var/tmp/go
/var/tmp/go
fi