Jump to content
Squid

Additional Scripts For User.Scripts Plugin

230 posts in this topic Last Reply

Recommended Posts

Can rsyncs be run using this plugin?  I get the following errors when I try to.

 

rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.2]

No fundamental reason why they couldn't be that I'm aware of

 

It could be more of an endpoint problem than an rsync problem.  Can you display the commands you are using?

Share this post


Link to post

Can rsyncs be run using this plugin?  I get the following errors when I try to.

 

rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.2]

No fundamental reason why they couldn't be that I'm aware of

 

It could be more of an endpoint problem than an rsync problem.  Can you display the commands you are using?

 

I've tried both of the following and get the same error regardless.  Running the commands locally in the console works fine.

 

rsync -avz --delete -e ssh 'root@10.0.10.208:/mnt/user/Movies/' '/mnt/user/Movies'

 

rsync -avz --delete 'root@10.0.10.208:/mnt/user/Movies/' '/mnt/user/Movies'

 

 

EDIT:  I'm realizing now my issue is the SSH password.  I need to figure out how to automate the SSH connection without having to enter the password.

 

Share this post


Link to post

Send server status to phone

 

I have made a script which sends server status to your phone or tablet using pushover or push bullet.

It sends

1. Running VMs

2. Running Dockers

3. Free Array space

4. Free cache space

5. Cpu core temperatures

 

You will need a pushover/push bullet account and will need to insert user key and a token into the script.

Maybe useful for people who want to check a vm used for cctv etc is running.

 

#!/bin/bash


#set whether to use pushnotication [0- none] [1-pushover] [2-pushbullet] 
pushnotifications="0"
#pushover api (only fill in if set above to pushover above)
apitoken="token=xxxxxxxxxxxxxxxxxxxx"
userkey="user=xxxxxxxxxxxxxxxxxxxx"
#pushbullet api (only fill in if set above to pushbullet above)
API="xxxxxxxxxxxxxxxxxxx"

#dont edit below this line#######################################################################

#set function "pushnotice" to push type

if [[ "$pushnotifications" =~ ^(1|2)$ ]]; then

	if [ "$pushnotifications" -eq 1 ]; then

		function pushnotice {
				 curl -s \
			--form-string $apitoken \
			--form-string $userkey \
			--form-string "message=$1" \
			https://api.pushover.net/1/messages.json
			}
			echo "set for pushover"


		elif [ "$pushnotifications" -eq 2 ]; then


			function pushnotice {
			curl -u $API: https://api.pushbullet.com/v2/pushes -d type=note -d title="unRAID status" -d body="$1"
			}

			echo "set for pushbullet"			

		fi

	else

		function pushnotice {
			echo "$1"
		}


	fi

vmsrunning=$(virsh list | awk '$1 == "-" || $1+0 > 0 { print $2 }')
docsrunning=$(docker ps | awk '{ print $2}')
temp=$(sensors | awk '{ print $1,$2,$3}')
hdspacefree=$(df -h /mnt/user/ ~ | awk 'NR==2 {print $4}')
cachespacefree=$(df -h /mnt/cache/ ~ | awk 'NR==2 {print $4}')		


#!send server status message
pushnotice "These VMs are running
$vmsrunning

These Dockers are running
$docsrunning

Array space left
$hdspacefree

Cache space left
$cachespacefree

temperatures

$temp
"



sleep 10
exit

 

Hopefully useful  :)

Server_info_push.zip

Share this post


Link to post

Send server status to phone

 

I have made a script which sends server status to your phone or tablet using pushover.

It sends

1. Running VMs

2. Running Dockers

3. Free Array space

4. Free cache space

5. Cpu core temperatures

 

Thanks for the idea.

modified it to work with pushbullet and added a couple other notifications too.

Share this post


Link to post

Send server status to phone

 

I have made a script which sends server status to your phone or tablet using pushover.

It sends

1. Running VMs

2. Running Dockers

3. Free Array space

4. Free cache space

5. Cpu core temperatures

 

Thanks for the idea.

modified it to work with pushbullet and added a couple other notifications too.

Love to know what extra functions did you put in your script? Good idea to do push bullet . So now i have edited the code in the script to give option of either. :)

 

Share this post


Link to post

Backup vm xml files and ovmf nvram files.

 

This script backs up vm xml files and ovmf nvram files to a folder of your choice.

they are put into a dated folder.

Just set the location in the script.

 

#!/bin/bash
#backs up
#change the location below to your backup location 
backuplocation="/mnt/user/test/"

# do not alter below this line
datestamp="_"`date '+%d_%b_%Y'`
dir="$backuplocation"/vmsettings/"$datestamp"
# dont change anything below here
if [ ! -d $dir ] ; then

		echo "making folder for todays date $datestamp"

		# make the directory as it doesnt exist
		mkdir -vp $dir
	else
		echo "As $dir exists continuing."
		fi

echo "Saving vm xml files"
rsync -a --no-o /etc/libvirt/qemu/*xml $dir/xml/
echo "Saving ovmf nvram"
rsync -a --no-o /etc/libvirt/qemu/nvram/* $dir/nvram/
chmod -R 777 $dir
sleep 5
exit

 

 

 

 

vm_settings_backup.zip

Share this post


Link to post

Automatically download from repo and install custom VM icons to vm manager

 

Here are a  couple of scripts that work together. These will download custom vm icons and gui banners from a website repo (which has a collection of vm icons that users have submitted and can contribute to) to a choosen store folder on array. Then install them, from there,  into the vm manager, by rsync to /usr/local/emhttp/plugins/dynamix.vm.manager/templates/images.

Optional push notifications on new icon downloads built into script.

 

For more info on how to setup please see this post  http://lime-technology.com/forum/index.php?topic=52609.0

 

 

 

 

 

Script 1 Icon_banner downloader

#!/bin/bash
#downloads custom icons from online icon repository to array then copies them into vm manager. 
#
#set below to [0 - First copies icons to category folders, so you can choose which icons to have copied to the system] 
#set below to [1 - direct downloads all icons without categories then copies them to your system without user choice]
direct_copy_icons="0"

#set location on server for download of icons if above not set to direct
downloadlocation="/mnt/user/test"
#
#
#optional push notifications set below leave all settings below if none required
#
#
#set whether to use pushnotication on download of new icons [0- none] [1-pushover] [2-pushbullet] 
pushnotifications="1"
#pushover api (only fill in if set above to pushover above)
apitoken="token=put your pushover token here"
userkey="user=put your pushover user key here"
#pushbullet api (only fill in if set above to pushbullet above)
API="put your push bullet api key here"

#dont change anything below here ***********************************************************************************
#
dirtemp=$downloadlocation"/icons/temp"
dirstore=$downloadlocation"/icons/store"
dirbanner=$downloadlocation"/icons/banners"
#set function "pushnotice" to push type

if [[ "$pushnotifications" =~ ^(1|2)$ ]]; then

	if [ "$pushnotifications" -eq 1 ]; then

		function pushnotice {
				 curl -s \
			--form-string $apitoken \
			--form-string $userkey \
			--form-string "message=$1" \
			https://api.pushover.net/1/messages.json
			}
			echo "set for pushover"


		elif [ "$pushnotifications" -eq 2 ]; then

			function pushnotice {
			curl -u $API: https://api.pushbullet.com/v2/pushes -d type=note -d title="unRAID vm icons" -d body="$1"
			}

			echo "set for pushbullet"			

		fi

	else

		function pushnotice {
			echo "$1"
		}

	fi
	if [ ! -d $dirtemp ] ; then

				echo "Setting up first folder $dirtemp "

				# make the temp directory as it doesnt exist
				mkdir -vp $dirtemp
			else
				echo "continuing."

				fi	
	#check if array if banner location exist
			if [ ! -d $dirbanner ] ; then

						echo "Setting up banner folder $dirbanner "

						# make the temp directory as it doesnt exist
						mkdir -vp $dirbanner
					else
						echo "continuing."

						fi	
		#check if array if store location exist				

			if [ ! -d $dirstore ] ; then

									echo "Setting up second folder $dirtemp "

									# make the store directory as it doesnt exist
									mkdir -vp $dirstore
								else
									echo "All folders needed are already created continuing."
									fi

if [[ "$direct_copy_icons" =~ ^(0|1)$ ]]; then


if [ "$direct_copy_icons" -eq 0 ]; then

# set download location to temp folder for user to sort
	echo "information: direct_copy_icons flag is 0. Icons will be copied to array first for manual sorting."
	download=$dirtemp
	#set wget to download with folder structure for user sorting
	get="-r -c -S -N -nH -e robots=off -np -A png -R index.html* http://spaceinvader.one/unraidvmicons/"
	getbanner="-r -c -S -N -nH -e robots=off -np -A png -R index.html* http://spaceinvader.one/unraidbanners/"
	#set what to do at end of script
	end=0



elif [ "$direct_copy_icons" -eq 1 ]; then

# set download location to store folder then copy to system
	echo "information: direct_copy_icons flag is 1.Icons will be copied directly to system without user intervention"



	download=$dirstore
	#set wget to download without folder structure as direct to system
	get="-r -c -S -N -nH -e robots=off -nd -np -A png -R index.html* http://spaceinvader.one/unraidvmicons/"
	getbanner="-r -c -S -N -nH -e robots=off -np -A png -R index.html* http://spaceinvader.one/unraidbanners/"
	#set what to do at end of script
	end=1
fi

else
echo "failure: direct_copy_icons is $direct_copy_icons. this is not a valid format. expecting [0 - array first] or [1 - direct to system]. exiting."

exit 1
fi


					echo "'______'''_______''_'''''_''__''''_''___''''''_______''_______''______'''___'''__''''_''_______'";
					echo "|''''''|'|'''''''||'|'_'|'||''|''|'||'''|''''|'''''''||'''_'''||''''''|'|'''|'|''|''|'||'''''''|";
					echo "|''_''''||'''_'''||'||'||'||'''|_|'||'''|''''|'''_'''||''|_|''||''_''''||'''|'|'''|_|'||''''___|";
					echo "|'|'|'''||''|'|''||'''''''||'''''''||'''|''''|''|'|''||'''''''||'|'|'''||'''|'|'''''''||'''|'__'";
					echo "|'|_|'''||''|_|''||'''''''||''_''''||'''|___'|''|_|''||'''''''||'|_|'''||'''|'|''_''''||'''||''|";
					echo "|'''''''||'''''''||'''_'''||'|'|'''||'''''''||'''''''||'''_'''||'''''''||'''|'|'|'|'''||'''|_|'|";
					echo "|______|'|_______||__|'|__||_|''|__||_______||_______||__|'|__||______|'|___|'|_|''|__||_______|";
					echo "'''''''''''''''''''''''''___'''_______''_______''__''''_''_______'''''''''''''''''''''''''''''''";
					echo "''''''''''''''''''''''''|'''|'|'''''''||'''''''||''|''|'||'''''''|''''''''''''''''''''''''''''''";
					echo "''''''''''''''''''''''''|'''|'|'''''''||'''_'''||'''|_|'||''_____|''''''''''''''''''''''''''''''";
					echo "''''''''''''''''''''''''|'''|'|'''''''||''|'|''||'''''''||'|_____'''''''''''''''''''''''''''''''";
					echo "''''''''''''''''''''''''|'''|'|''''''_||''|_|''||''_''''||_____''|''''''''''''''''''''''''''''''";
					echo "''''''''''''''''''''''''|'''|'|'''''|_'|'''''''||'|'|'''|'_____|'|''''''''''''''''''''''''''''''";
					echo "''''''''''''''''''''''''|___|'|_______||_______||_|''|__||_______|''''''''''''''''''''''''''''''";


firstcount=$(find $dirtemp -type f | wc -l)	
firstcount2=$(find $dirstore -type f | wc -l)
bannercount=$(find $dirbanner -type f | wc -l)		 
sleep 10
wget $get -P $download
wget $getbanner -P $dirbanner
sleep 3
lastcount=$(find $dirtemp -type f | wc -l)	
lastcount2=$(find $dirstore -type f | wc -l)
bannercount2=$(find $dirbanner -type f | wc -l)	
totalnew=$(($lastcount - $firstcount))
totalnew2=$(($lastcount2 - $firstcount2))
bannernew=$(($bannercount2 - $bannercount))


if [[ "$direct_copy_icons" =~ ^(0|1)$ ]]; then


		if [ "$direct_copy_icons" -eq 0 ]; then
			#display message
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''''¶¶¶¶'''''''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''¶´´´´¶¶'''''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''¶´´´´´¶'''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''''¶´´´´¶'''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''''¶´´´¶''''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''¶¶¶¶¶¶¶¶¶¶¶¶'''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´¶''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´¶'''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''¶¶´´´¶¶¶¶¶¶¶¶¶¶¶''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´´´´¶'''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´´´´¶'''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''¶´´´¶¶¶¶¶¶¶¶¶¶¶''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´¶'''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''¶¶¶¶¶¶¶¶¶¶¶''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "'''''''''_______''___''''''___''''''''______'''_______''__''''_''_______'''''''''";
			echo "''''''''|'''_'''||'''|''''|'''|''''''|''''''|'|'''''''||''|''|'||'''''''|''''''''";
			echo "''''''''|''|_|''||'''|''''|'''|''''''|''_''''||'''_'''||'''|_|'||''''___|''''''''";
			echo "''''''''|'''''''||'''|''''|'''|''''''|'|'|'''||''|'|''||'''''''||'''|___'''''''''";
			echo "''''''''|'''''''||'''|___'|'''|___'''|'|_|'''||''|_|''||''_''''||''''___|''''''''";
			echo "''''''''|'''_'''||'''''''||'''''''|''|'''''''||'''''''||'|'|'''||'''|___'''''''''";
			echo "''''''''|__|'|__||_______||_______|''|______|'|_______||_|''|__||_______|''''''''";
			echo "'''''''''__''''_''_______''_'''''_''''_______''_______''______''''_______''''''''";
			echo "''''''''|''|''|'||'''''''||'|'_'|'|''|'''''''||'''''''||''''_'|''|'''''''|'''''''";
			echo "''''''''|'''|_|'||'''_'''||'||'||'|''|''_____||'''_'''||'''|'||''|_'''''_|'''''''";
			echo "''''''''|'''''''||''|'|''||'''''''|''|'|_____'|''|'|''||'''|_||_'''|'''|'''''''''";
			echo "''''''''|''_''''||''|_|''||'''''''|''|_____''||''|_|''||''''__''|''|'''|'''''''''";
			echo "''''''''|'|'|'''||'''''''||'''_'''|'''_____|'||'''''''||'''|''|'|''|'''|'''''''''";
			echo "''''''''|_|''|__||_______||__|'|__|''|_______||_______||___|''|_|''|___|'''''''''";
			echo "'__'''__''_______''__'''__''______''''''___'''_______''_______''__''''_''_______'";
			echo "|''|'|''||'''''''||''|'|''||''''_'|''''|'''|'|'''''''||'''''''||''|''|'||'''''''|";
			echo "|''|_|''||'''_'''||''|'|''||'''|'||''''|'''|'|'''''''||'''_'''||'''|_|'||''_____|";
			echo "|'''''''||''|'|''||''|_|''||'''|_||_'''|'''|'|'''''''||''|'|''||'''''''||'|_____'";
			echo "|_'''''_||''|_|''||'''''''||''''__''|''|'''|'|''''''_||''|_|''||''_''''||_____''|";
			echo "''|'''|''|'''''''||'''''''||'''|''|'|''|'''|'|'''''|_'|'''''''||'|'|'''|'_____|'|";
			echo "''|___|''|_______||_______||___|''|_|''|___|'|_______||_______||_|''|__||_______|";
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "Sort your icons located at $dirtemp and put the ones you want into $dirstore"
			if [ "$lastcount" -gt "$firstcount" ]; then

						pushnotice "$totalnew new icons downloaded to $dirtemp ready for sorting"



					else
						echo "No new icons downloaded"
						fi



			elif [ "$direct_copy_icons" -eq 1 ]; then
			#rysnc downloaded icons to dynamix.vm.manager/templates/images then display message
			rsync -a $dirstore/* /usr/local/emhttp/plugins/dynamix.vm.manager/templates/images

			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''''¶¶¶¶'''''''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''¶´´´´¶¶'''''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''¶´´´´´¶'''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''''¶´´´´¶'''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''''¶´´´¶''''''''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''¶¶¶¶¶¶¶¶¶¶¶¶'''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´¶''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´¶'''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''¶¶´´´¶¶¶¶¶¶¶¶¶¶¶''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´´´´¶'''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´´´´´¶'''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''¶´´´¶¶¶¶¶¶¶¶¶¶¶''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''¶´´´´´´´´´´´¶'''''''''''''''''''''''''''''''";
			echo "''''''''''''''''''''''''''''''''''''''¶¶¶¶¶¶¶¶¶¶¶''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "'''''''''''_______''___''''''___''''''''______'''_______''__''''_''_______'''''''";
			echo "''''''''''|'''_'''||'''|''''|'''|''''''|''''''|'|'''''''||''|''|'||'''''''|''''''";
			echo "''''''''''|''|_|''||'''|''''|'''|''''''|''_''''||'''_'''||'''|_|'||''''___|''''''";
			echo "''''''''''|'''''''||'''|''''|'''|''''''|'|'|'''||''|'|''||'''''''||'''|___'''''''";
			echo "''''''''''|'''''''||'''|___'|'''|___'''|'|_|'''||''|_|''||''_''''||''''___|''''''";
			echo "''''''''''|'''_'''||'''''''||'''''''|''|'''''''||'''''''||'|'|'''||'''|___'''''''";
			echo "''''''''''|__|'|__||_______||_______|''|______|'|_______||_|''|__||_______|''''''";
			echo "'''''''___'''_______''_______''__''''_''_______''''__''''_''_______''_'''''_'''''";
			echo "''''''|'''|'|'''''''||'''''''||''|''|'||'''''''|''|''|''|'||'''''''||'|'_'|'|''''";
			echo "''''''|'''|'|'''''''||'''_'''||'''|_|'||''_____|''|'''|_|'||'''_'''||'||'||'|''''";
			echo "''''''|'''|'|'''''''||''|'|''||'''''''||'|_____'''|'''''''||''|'|''||'''''''|''''";
			echo "''''''|'''|'|''''''_||''|_|''||''_''''||_____''|''|''_''''||''|_|''||'''''''|''''";
			echo "''''''|'''|'|'''''|_'|'''''''||'|'|'''|'_____|'|''|'|'|'''||'''''''||'''_'''|''''";
			echo "''''''|___|'|_______||_______||_|''|__||_______|''|_|''|__||_______||__|'|__|''''";
			echo "'''''''''''''''''''______''''_______''_______''______'''__'''__''''''''''''''''''";
			echo "''''''''''''''''''|''''_'|''|'''''''||'''_'''||''''''|'|''|'|''|'''''''''''''''''";
			echo "''''''''''''''''''|'''|'||''|''''___||''|_|''||''_''''||''|_|''|'''''''''''''''''";
			echo "''''''''''''''''''|'''|_||_'|'''|___'|'''''''||'|'|'''||'''''''|'''''''''''''''''";
			echo "''''''''''''''''''|''''__''||''''___||'''''''||'|_|'''||_'''''_|'''''''''''''''''";
			echo "''''''''''''''''''|'''|''|'||'''|___'|'''_'''||'''''''|''|'''|'''''''''''''''''''";
			echo "''''''''''''''''''|___|''|_||_______||__|'|__||______|'''|___|'''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''";
			echo "              Icons are now ready to use and available in vm manager.            "

			if [ "$lastcount2" -gt "$firstcount2" ]; then

						pushnotice "$totalnew2 new icons downloaded your vm manager"


					else
						echo "No new icons downloaded"
						fi



		fi


	else


		echo "."	


	fi



	if [ "$bannercount2" -gt "$bannercount" ]; then

				pushnotice "$bannernew new banners downloaded to $dirbanner "





			else
				echo "No new banners downloaded"
				fi


exit 0

 

script 2 Icon sysnc

#!/bin/bash
# this script works with icon_banner downloader
# It syncs the vm icon store on icon store folder on array with /usr/local/emhttp/plugins/dynamix.vm.manager/templates/images

#set location on server for download of icons same location as icon_banner downloader else script will not work
downloadlocation="/mnt/user/test"
# do not change anything below this line

dirstore=$downloadlocation"/icons/store"
#check if above location exist				

if [ ! -d $dirstore ] ; then

						echo "$dirtemp does not exist please check you have icon_banner downloader script installed and run at least once and downloadlocation is set in this script the same "


					else
						echo "Ok evrything looks how it should. Syncing vm icon store with dynamix.vm.manager "
						fi
rsync -a $dirstore/* /usr/local/emhttp/plugins/dynamix.vm.manager/templates/images

sleep 5
exit

 

 

 

 

icon_scripts.zip

Share this post


Link to post

Clear an unRAID array data drive

 

When running this, the following was displayed:

Unmounting Disk 1 ...
umount: /mnt/disk1: target is busy

 

It still seems to be clearing. What is the purpose of unmounting?  Will I be able to remove the drive when it's done?

 

EDIT:

The display says it's going crazy slow:

23768072192 bytes (24 GB, 22 GiB) copied, 35769.9 s, 664 kB/s

 

What would the consequences be of closing the window?

Share this post


Link to post

Clear an unRAID array data drive

 

When running this, the following was displayed:

Unmounting Disk 1 ...
umount: /mnt/disk1: target is busy

 

It still seems to be clearing. What is the purpose of unmounting?

The drive must be unmounted before using the dd command.  Because unmounting has always worked without issue, I never thought to check for success or failure.  I'll need to check that, and abort if not able to unmount the drive.

 

Since it passed the earlier tests, it seems impossible for a file to be open, so the only way I can think of to fail unmounting it is because a terminal or console session was open on the drive, perhaps where you were working before starting the script.  I'll need to check for that, and if possible request the console session be closed.

 

Will I be able to remove the drive when it's done?

 

EDIT:

The display says it's going crazy slow:

23768072192 bytes (24 GB, 22 GiB) copied, 35769.9 s, 664 kB/s

 

What would the consequences be of closing the window?

 

I don't know what is happening at the moment, as the drive was probably not unmounted.  It appears to be running the dd command, but dd does not provide good error reporting.  I do not think it is clearing the drive, so it should be aborted.

 

Because scripts in the foreground seem to hang emhttp (the unRAID core), you will probably have to shut down and reboot.  You may have to re-format and prep the drive, then rerun the script, making sure there are no console sessions open, set to a 'current directory' on the drive being cleared.

Share this post


Link to post

Because scripts in the foreground seem to hang emhttp (the unRAID core), you will probably have to shut down and reboot. 

Closing the window will abort the script.  But, any long running child processes that are spawned (ie: dd), will remain running until completion.  However that shouldn't affect emhttp

Share this post


Link to post

I went ahead and closed the script window, which did bring the Web interface back.  I downloaded diagnostics (attached), and then tried to stop the array.  That seems to have caused me to lose the interface, but I still have a console session.  "top" shows unraidd still working, and the syslog shows the following error repeated many times:

Oct 22 15:53:41 SF-unRAID kernel: XFS (md1): xfs_log_force: error -5 returned.

 

Is there a safe way to shut down at this point?

sf-unraid-diagnostics-20161022-1349.zip

Share this post


Link to post

I went ahead and closed the script window, which did bring the Web interface back.  I downloaded diagnostics (attached), and then tried to stop the array.  That seems to have caused me to lose the interface, but I still have a console session.  "top" shows unraidd still working, and the syslog shows the following error repeated many times:

Oct 22 15:53:41 SF-unRAID kernel: XFS (md1): xfs_log_force: error -5 returned.

 

Is there a safe way to shut down at this point?

That would be expected - if a bit of clearing occurred, there's no file system left, so XFS is confused.

 

Shut it down any way you can.  Try these in this order, until one works:

- at command prompt: powerdown

- at command prompt: poweroff

- push power button

- push and hold power button

 

On the next boot, if it complains of 'unclean shutdown' and wants to start a parity check, just cancel it.

Share this post


Link to post

Shut it down any way you can.  Try these in this order, until one works:

- at command prompt: powerdown

- at command prompt: poweroff

- push power button

- push and hold power button

 

On the next boot, if it complains of 'unclean shutdown' and wants to start a parity check, just cancel it.

 

Thanks. I had to hold the power button to get it to shut down, but it didn't indicate an unclean shutdown when I booted back up.  I changed the disk format for disk1, brought the array online, formatted the disk, and created the clear-me folder.

 

I've modified the script, replacing the umount $d line with the following:

if ! umount $d; then
echo -e "\rFailed to unmount disk. Exiting ..."
logger -tclear_array_drive "Failed to unmount disk. Exiting ..."
exit
fi

 

I'm just going by the answer here.  Do you think this is sufficient to ensure the disk is unmounted?  I guess it would exit if the drive somehow became unmounted during the 60 second wait before the umount command is issued, so it's not bulletproof.

Share this post


Link to post

Run A Custom Script At Parity Check / Rebuild Start And Stop

Use it to run a custom script to (as an example), shut down various docker applications, etc.  Adjust the variables within the script file.

 

Note that you either need to run this in the background or at array start.  Running this in the foreground will not work.

 

#!/usr/bin/php
<?PHP
# A simple script to allow you to run a custom script when a parity check starts or stops
# Adjust the following variables to suit:

$checkInterval = 300;                             # Number of seconds in between checks
$startScript   = "full path to the script";       # The full path to the script to run when a parity check starts
$stopScript    = "full path to the stop script";  # The full path to the script to run when a parity check stops

# Don't touch anything below

while (true) {
  $vars = parse_ini_file("/var/local/emhttp/var.ini");
  if ( $vars['mdState'] == "STOPPED" ) {
    break;
  }
  if ( ($vars['mdResyncPos'] != 0) && $vars ) {
    echo "Parity Check / Sync / Rebuild in progress.  Executing the start script ($startScript)";
    exec($startScript,$output);
    foreach ($output as $line) {
      echo $line."\n";
    }
    while (true) {
      $vars = parse_ini_file("var/local/emhttp/var.ini");
      if ( ($vars['mdResyncPos'] == 0) && $vars ) {
        echo "Parity Check / Sync / Rebuild finished.  Executing the stop script ($stopScript)";
        exec($stopScript,$output);
        foreach ($output as $line) {
          echo $line."\n";
        }
        break;
      } else {
        sleep($checkInterval);
      }
    }
  } else { 
    sleep($checkInterval);
  }  
}
?>

custom_script_parity_check_start_stop.zip

Share this post


Link to post

Thank you Squid for the custom script at parity check script. It worked perfectly.

I just wrote two simple scripts with

#!/bin/bash

docker stop Plex

 

And another with

#!/bin/bash

docker start Plex

 

Thanks for everything!

 

Share this post


Link to post

Thank you Squid for the custom script at parity check script. It worked perfectly.

I just wrote two simple scripts with

#!/bin/bash

docker stop Plex

 

And another with

#!/bin/bash

docker start Plex

 

Thanks for everything!

 

 

Can I ask why you've done this?  Does parity build mess up Plex? My parity only got added yesterday while I was away from home, so I don't know how it affects overall performance

Share this post


Link to post

A slightly enhanced version of the run mover at a certain threshold script.  This script additionally will skip running mover (optional) if a parity check / rebuild has already been started.

 

Only makes sense to run this script on a schedule, and disable the built-in schedule by editing the config/share.cfg file on the flash drive.  Look for a like that says something like:

shareMoverSchedule="0 4 * * *"

and change it to:

shareMoverSchedule="#0 4 * * *"

 

Followed by a reboot.  Note that any changes to global share settings ( or mover settings ) is probably going to wind up re-enabling the mover schedule

 

 

#!/usr/bin/php
<?PHP
$moveAt = 0;                 # Adjust this value to suit (% cache drive full to move at)
$runDuringCheck = false;     # change to true to run mover during a parity check / rebuild

$diskTotal = disk_total_space("/mnt/cache");
$diskFree = disk_free_space("/mnt/cache");
$percent = ($diskTotal - $diskFree) / $diskTotal * 100;

if ( $percent > $moveAt ) {
  if ( ! $runDuringCheck ) {
    $vars = parse_ini_file("/var/local/emhttp/var.ini");
    if ( $vars['mdResync'] ) {
      echo "Parity Check / Rebuild Running - Not executing mover\n";
      exec("logger Parity Check / Rebuild Running - Not executing mover");
    } else {
      exec("/usr/local/sbin/mover");
    }
  } else {
    exec("/usr/local/sbin/mover");
  }
}
?>

 

 

Does this script still work for you?  It'd be perfect for my setup, but it never seems to kick in and move files

 

 

#!/bin/php
#description=Run mover at a certain threshold of cache drive utilization. 


#!/usr/bin/php
<?PHP
$moveAt = 75;                 # Adjust this value to suit (% cache drive full to move at)
$runDuringCheck = false;     # change to true to run mover during a parity check / rebuild


$diskTotal = disk_total_space("/mnt/cache");
$diskFree = disk_free_space("/mnt/cache");
$percent = ($diskTotal - $diskFree) / $diskTotal * 100;


if ( $percent > $moveAt ) {
  if ( ! $runDuringCheck ) {
    $vars = parse_ini_file("/var/local/emhttp/var.ini");
    if ( $vars['mdResync'] ) {
      echo "Parity Check / Rebuild Running - Not executing mover\n";
      exec("logger Parity Check / Rebuild Running - Not executing mover");
    } else {
      exec("/usr/local/sbin/mover");
    }
  } else {
    exec("/usr/local/sbin/mover");
  }
}
?>

Share this post


Link to post

A slightly enhanced version of the run mover at a certain threshold script.  This script additionally will skip running mover (optional) if a parity check / rebuild has already been started.

 

Only makes sense to run this script on a schedule, and disable the built-in schedule by editing the config/share.cfg file on the flash drive.  Look for a like that says something like:

shareMoverSchedule="0 4 * * *"

and change it to:

shareMoverSchedule="#0 4 * * *"

 

Followed by a reboot.  Note that any changes to global share settings ( or mover settings ) is probably going to wind up re-enabling the mover schedule

 

 

#!/usr/bin/php
<?PHP
$moveAt = 0;                 # Adjust this value to suit (% cache drive full to move at)
$runDuringCheck = false;     # change to true to run mover during a parity check / rebuild

$diskTotal = disk_total_space("/mnt/cache");
$diskFree = disk_free_space("/mnt/cache");
$percent = ($diskTotal - $diskFree) / $diskTotal * 100;

if ( $percent > $moveAt ) {
  if ( ! $runDuringCheck ) {
    $vars = parse_ini_file("/var/local/emhttp/var.ini");
    if ( $vars['mdResync'] ) {
      echo "Parity Check / Rebuild Running - Not executing mover\n";
      exec("logger Parity Check / Rebuild Running - Not executing mover");
    } else {
      exec("/usr/local/sbin/mover");
    }
  } else {
    exec("/usr/local/sbin/mover");
  }
}
?>

 

 

Does this script still work for you?  It'd be perfect for my setup, but it never seems to kick in and move files

 

 

#!/bin/php
#description=Run mover at a certain threshold of cache drive utilization. 


#!/usr/bin/php
<?PHP
$moveAt = 75;                 # Adjust this value to suit (% cache drive full to move at)
$runDuringCheck = false;     # change to true to run mover during a parity check / rebuild


$diskTotal = disk_total_space("/mnt/cache");
$diskFree = disk_free_space("/mnt/cache");
$percent = ($diskTotal - $diskFree) / $diskTotal * 100;


if ( $percent > $moveAt ) {
  if ( ! $runDuringCheck ) {
    $vars = parse_ini_file("/var/local/emhttp/var.ini");
    if ( $vars['mdResync'] ) {
      echo "Parity Check / Rebuild Running - Not executing mover\n";
      exec("logger Parity Check / Rebuild Running - Not executing mover");
    } else {
      exec("/usr/local/sbin/mover");
    }
  } else {
    exec("/usr/local/sbin/mover");
  }
}
?>

Yes it works fine (just tested)  You don't see anything in the syslog about mover running, but it does.

 

Couple of notes:

 

If you have the "description" file present (which was included with the script), then your description= comment is ignored.

 

Any comment lines with PHP scripts should come after the <? or <?PHP line.  While it doesn't actually affect execution having them in there before, those excess lines are actually echoed to the console (ie: they go to the script's log) and are not treated as comments.  Just the way PHP works.  I included an exception for PHP scripts (since that's how I do the vast majority of my scripts) that the comment variables can come immediately after the <? or <?PHP unlike bash scripts where it must be immediately after the #!/usr/bin/bash

Share this post


Link to post

Yes it works fine (just tested)  You don't see anything in the syslog about mover running, but it does.

 

Couple of notes:

 

If you have the "description" file present (which was included with the script), then your description= comment is ignored.

 

Any comment lines with PHP scripts should come after the <? or <?PHP line.  While it doesn't actually affect execution having them in there before, those excess lines are actually echoed to the console (ie: they go to the script's log) and are not treated as comments.  Just the way PHP works.  I included an exception for PHP scripts (since that's how I do the vast majority of my scripts) that the comment variables can come immediately after the <? or <?PHP unlike bash scripts where it must be immediately after the #!/usr/bin/bash

 

 

Hmm my cache free space never goes up and I have to always run mover manually.  Even when I hit 'run in background' for the script manually it never seems to work. 

 

 

Have I disabled mover correctly?

 

 

shareMoverSchedule="#0 1 * * *"

Share this post


Link to post

Is the cache drive more than 75% full?

 

Share this post


Link to post

Is the cache drive more than 75% full?

 

 

Yes when I spot the script isn't working -  My cache drive is 250GB and when it's at say 20GB free, I'll try running the script in the background and nothing happens so I either end up using the mover manually or going into mc and moving files.

Share this post


Link to post

Had a better look at the script you posted, and you added in #!/bin/php which is incorrect.  Should be #!/usr/bin/php (which is what it was originally as shown a couple of lines down)

Share this post


Link to post

Well... I have an idea for a script, but my shell scripting is not quite up to snuff. Irony is I could make this in powershell really quick, but I'd rather this ran natively in unraid... Anyone want to lend a hand?

 

Idea:

A script that dumps an inventory of each disk using the 'tree' command (tree /mnt/disk1 > /boot/config/diskContents/disk1/$timestamp.txt) It should be able to 'logrotate' so we're keeping X (14?) number of days history.

 

Think of it as a hard copy listing of each disk's contents in case you have a catastrophic disk failure and need to rebuild after rebuilding.

 

 

Sound useful to anyone else?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now