]> rm /tmp/&name;.sh # cleanup possibly failed previous download/install attempt rm -rf /tmp/&name;* mkdir /tmp/&name; # check if this is unRAID-5 source /etc/unraid-version if [[ "${version:0:2}" == "5." ]]; then # prevent endless install loop rm -rf /boot/plugins/&name;.plg rm -rf /boot/config/plugins/&name;.plg # check if 64-bit capable CPU if ! grep -q " lm" /proc/cpuinfo ; then echo "CPU is not 64-bit capable" exit 1 fi # Wait until network is ready by pinging google - thanks bonienl! ip=8.8.4.4 timer=30 while [[ $timer -gt 0 ]]; do if [[ -n $(route -n|awk '/^0.0.0.0/{print $2}') && $(ping -qnc1 $ip|awk '/received/{print $4}') -eq 1 ]]; then break fi ((timer--)) sleep 1 done if [[ $timer -eq 0 ]]; then echo "No network communication !!!" exit 1 fi # unRAID-5 needs infozip if [ ! -f /boot/extra/&infozip; ]; then echo "Downloading &infozip; package" mkdir -p /boot/extra wget http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/a/&infozip; -O /boot/extra/&infozip; upgradepkg --install-new /boot/extra/&infozip; fi # download the release if ! wget --no-check-certificate &zip; -O /tmp/&name;.zip ; then echo "&zip; download error $?" exit 1 fi if ! wget --no-check-certificate &md5; -O /tmp/&name;.md5 ; then echo "&md5; download error $?" exit 1 fi fi &zip; &md5; rm /tmp/&name;.sh # check download and extract sum1=$(/usr/bin/md5sum /tmp/&name;.zip) sum2=$(cat /tmp/&name;.md5) if [[ "${sum1:0:32}" != "${sum2:0:32}" ]]; then echo "wrong md5" exit 1 fi if ! unzip -d /tmp/&name; /tmp/&name;.zip ; then echo "unzip error $?" exit 1 fi # check if enough free space on flash have=$(df -k /boot | awk ' END { print $4 } ') need=$(du -Ssk /tmp/&name; | awk ' END { print $1 } ') source /etc/unraid-version if [[ "${version:0:2}" == "5." ]]; then # to permit another upgrade need=$(($need * 2)) fi # add some margin for possible additional config info need=$(($need + 8192)) if [[ $need -gt $have ]]; then echo "boot device shows $have free but upgrade needs $need" exit 1 fi # move release files to flash mkdir -p /boot/&name; rm -rf /boot/&name;/* if ! mv /tmp/&name;/{&files;} /boot/&name; ; then echo "flash write error $?, maybe corrupted?" rm -rf /boot/&name;/* exit 1 fi # preserve previous version source /etc/unraid-version if [[ "${version:0:2}" == "6." ]]; then mkdir -p /boot/previous rm -rf /boot/previous/* mv /boot/{&files;} /boot/previous else mkdir -p /boot/unRAID5 rm -rf /boot/unRAID5/* # preserve all files in root of flash except ldlinux.sys needed to boot find /boot -maxdepth 1 -type f -not -name ldlinux.sys -exec mv {} /boot/unRAID5 \; # preserve a few directories mv /boot/extra /boot/unRAID5 &> /dev/null mv /boot/packages /boot/unRAID5 &> /dev/null mv /boot/plugins /boot/unRAID5 &> /dev/null mkdir /boot/unRAID5/config mv /boot/config/plugins /boot/unRAID5/config &> /dev/null # grab a fresh 'go' file mv /boot/config/go /boot/unRAID5/config cp /tmp/&name;/config/go /boot/config # ensure key file is in the 'config' directory cp /boot/unRAID5/*.key /boot/config &> /dev/null fi # move new version files into place mv /boot/&name;/* /boot rmdir /boot/&name; # move the new syslinux.cfg- in to the syslinux folder if [[ -f /boot/syslinux.cfg- ]]; then mv /boot/syslinux.cfg- /boot/syslinux fi # if unRaid-6 replace the readme file if [[ "${version:0:2}" == "6." ]]; then echo "**REBOOT REQUIRED!**" > /usr/local/emhttp/plugins/&name;/README.md fi # if unRaid-6.3 ensure GUI Safe Mode syslinux option exists if [[ "${version:0:3}" == "6.3" ]]; then if ! grep -q 'initrd=/bzroot,/bzroot-gui unraidsafemode' /boot/syslinux/syslinux.cfg &> /dev/null ; then sed -i 's|label Memtest86+|label unRAID OS GUI Safe Mode (no plugins)\r\n kernel /bzimage\r\n append initrd=/bzroot,/bzroot-gui unraidsafemode\r\nlabel Memtest86+|g' /boot/syslinux/syslinux.cfg &> /dev/null fi fi # when upgrading any version prior to 6.2 if [[ "${version:0:3}" < "6.2" ]]; then if ! grep -q '/bzroot-gui' /boot/syslinux/syslinux.cfg &> /dev/null ; then sed -i 's|menu title Lime Technology\r|menu title Lime Technology, Inc.\r|g' /boot/syslinux/syslinux.cfg &> /dev/null sed -i 's|label unRAID OS Safe Mode (no plugins)|label unRAID OS GUI Mode\r\n kernel /bzimage\r\n append initrd=/bzroot,/bzroot-gui\r\nlabel unRAID OS Safe Mode (no plugins, no GUI)|g' /boot/syslinux/syslinux.cfg &> /dev/null fi fi # when upgrading any version prior to 6.1 if [[ "${version:0:3}" < "6.1" ]]; then if ! grep -q 'shareDisk' /boot/config/share.cfg &> /dev/null ; then echo 'shareDisk="yes"' >> /boot/config/share.cfg fi fi # when upgrading from 6.0.x if [[ "${version:0:3}" == "6.0" ]]; then sed -i 's|dynamix.docker.manager/dockerupdate.php|dynamix.docker.manager/scripts/dockerupdate.php|g' /boot/config/plugins/dynamix/docker-update.cron &> /dev/null sed -i 's|sbin/monitor|emhttp/plugins/dynamix/scripts/monitor|g' /boot/config/plugins/dynamix/monitor.cron &> /dev/null sed -i 's|/root/mdcmd|/usr/local/sbin/mdcmd|g' /boot/config/plugins/dynamix/parity-check.cron &> /dev/null sed -i 's|sbin/plugincheck|emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck|g' /boot/config/plugins/dynamix/plugin-check.cron &> /dev/null sed -i 's|sbin/statuscheck|emhttp/plugins/dynamix/scripts/statuscheck|g' /boot/config/plugins/dynamix/status-check.cron &> /dev/null fi # if template-repos does not exist if [[ ! -e /boot/config/plugins/dockerMan/template-repos ]]; then mkdir -p /boot/config/plugins/dockerMan echo "https://github.com/limetech/docker-templates" > /boot/config/plugins/dockerMan/template-repos fi # correct initial EFI syslinux.cfg if [[ -d /boot/EFI/boot && "${version}" == "6.4.0-rc4" ]]; then cp /tmp/&name;/EFI-/boot/syslinux.cfg /boot/EFI/boot fi # if EFI or EFI- directory does not exist if [[ ! -e /boot/EFI && ! -e /boot/EFI- ]]; then mv /tmp/&name;/EFI- /boot sed -i 's|default /syslinux/menu.c32|default menu.c32|g' /boot/syslinux/syslinux.cfg &> /dev/null fi # if metric appended to GATEWAY get rid of it if [[ -f /boot/config/network.cfg ]]; then sed -ri 's|^(GATEWAY.+)#[0-9]+|\1|' /boot/config/network.cfg fi echo "syncing - please wait..." sync echo "Update successful - PLEASE REBOOT YOUR SERVER" rm /tmp/&name;.sh # unRAID-5 doesn't support 'remove' method, so we're done source /etc/unraid-version if [[ "${version:0:2}" == "5." ]]; then exit 0 fi if [[ -d /boot/previous ]]; then # restore previous unRAID-6 release mv /boot/previous/* /boot rmdir /boot/previous echo "**REBOOT REQUIRED!**" > /usr/local/emhttp/plugins/&name;/README.md elif [[ -d /boot/unRAID5 ]]; then # restore previous unRAID-5 release rm -rf /boot/extra mv /boot/unRAID5/extra /boot &> /dev/null rm -rf /boot/plugins mv /boot/unRAID5/plugins /boot &> /dev/null rm -rf /boot/packages mv /boot/unRAID5/packages /boot &> /dev/null rm -rf /boot/config/plugins mv /boot/unRAID5/config/plugins /boot/config &> /dev/null mv /boot/unRAID5/config/go /boot/config rmdir /boot/unRAID5/config mv /boot/unRAID5/* /boot rmdir /boot/unRAID5 else echo "Cannot remove, no previous version" exit 1 fi echo "syncing..." sync echo "Remove successful - PLEASE REBOOT YOUR SERVER"