August 13, 20205 yr 3 minutes ago, jowi said: Yeah ok but why then use the user script module anyway at all, and not just run my python script (like i did before....) as a cron job or daemon.... IMHO CA User Script is just a GUI for simplifying the process of setting up cronjobs. If you know what you are doing, you absolutely could just setup the cronjobs yourself.
August 15, 20205 yr In my case - when i use a python script that needs the home directory - the program is not raising an exception but does not find the config file in the home directory and therefore not initialized properly. Some more detail about home directory is not set correctly issue. If i install a script in the plugin that relies on the home directory than if it is executed from the crontab, then it works. So the "run script" and "run in background" buttons are malfunctioning in such cases.
August 15, 20205 yr yes, i have tried the sudo version: sudo -i -u root /tmp/test.py It works! But i dont want to write a script to execute another one.
August 15, 20205 yr Dear @Squid I dont know too much about php, but i tried to debug your plugin. I have figured out, that the startScript.sh file already has the symtom that the HOME directory is not set. But with a 2 line modification i could fix the problem. I kindly ask you to examine my modification and if you agree, than please add it to your plugin, so others will have the fix too. Quote #!/bin/bash echo "Script location: <b>$1</b>" export HOME=$(grep $(whoami) /etc/passwd | cut -d: -f 6) source ${HOME}/.bashrc echo "<font color='red'>Note that closing this window will abort the execution of this script</font>" "$1" "$2" 2>&1 With this modification my python plugin works too Actually i need only the export command and not the source. I thought that it could be useful for others in the future to try to initialize the environment as much close to the login shell as possible. What is your opinion?
August 15, 20205 yr I have been using User Scripts with no problem for a long time. I tried to modify the timings of my some of my tasks, and APPLY and DONE does nothing. The button is clicked, but no action is taken and refreshing the page leads to old settings. Not working in chrome, IE or Firefox. How can i save my updated changes. NOTE: I also have one user script with an @ in the title and the cog is completely unclickable, not sure if this is related. If i could remove that too would be great. bigrig-diagnostics-20200815-1326.zip Edited August 15, 20205 yr by mihcox
August 15, 20205 yr 1 hour ago, mihcox said: I also have one user script with an @ in the title and the cog is completely unclickable Check the browser developer tools (F12 -> Console in Chrome). I bet there are javascript errors listed.
August 15, 20205 yr 41 minutes ago, mgutt said: Check the browser developer tools (F12 -> Console in Chrome). I bet there are javascript errors listed. Errors appear related to the @Reports... How can i manually remove this, as the gui does not respond when i click on it.
August 15, 20205 yr 27 minutes ago, mihcox said: How can i manually remove this, as the gui does not respond when i click on it. I tried it by myself. You can bypass this error by right mouse click -> inspect element and then remove the "@" symbol of the "id" attribut as shown in this screenshot (so it becomes id="nametest") After that the cog works and you are able to delete this script (and add a new one without the @ symbol in the name).
August 15, 20205 yr 6 minutes ago, mgutt said: I tried it by myself. You can bypass this error by right mouse click -> inspect element and then remove the "@" symbol of the "id" attribut as shown in this screenshot (so it becomes id="nametest") After that the cog works and you are able to delete this script (and add a new one without the @ symbol in the name). Resolved both issues, thank you!
August 24, 20205 yr Hi Squid, Great plugin ! I have more than 25 scripts runing daily thanks to you. Could be possible to implement something like "Docker Folder" ? It would be much easier to organize large amounts of scripts. That would be awesome ! Thanks !
September 15, 20205 yr On 8/23/2020 at 9:55 PM, Marcel_Costa said: Hi Squid, Great plugin ! I have more than 25 scripts runing daily thanks to you. Could be possible to implement something like "Docker Folder" ? It would be much easier to organize large amounts of scripts. That would be awesome ! Thanks ! wow, this is what i was coming here for too! my scripts are starting to stack up, would love to be able to organize them in a folder type structure. i.e. array scripts, backup scripts, VM scripts, etc. Goes without saying, Squid, great plugin for sure.
September 16, 20205 yr Thanks for the plugin! I have a question about permissions. I am in the process of migrating my Plex/NAS server from a Mac. On my Mac I have a script that syncs new files every 5 minutes from a remote seedbox. I have altered this script for UnRAID to download to my "Downloads" share. It appears to work fine as far as the syncing goes, but the files on the share are read-only and I can't do anything about that. What should I do to make it so I can have read/write permissions from my other devices when I access the share? Thanks! Here's the script: #!/bin/bash #### Seedbox Sync # # Sync various directories between home and seedbox, do some other things also. SCRIPT_NAME="$(basename "$0")" LOG_DIR="/mnt/user/Downloads/Seedbox/Scripts/Logs" SYNC_LOG="$SCRIPT_NAME.log" LOG_FILE="$LOG_DIR/$SYNC_LOG" USERNAME='***' PASS='***' HOST='***' PORT='***' # Number of files to download simultaneouslyvupv # Number of segments/parts to split the downloads into # Minimum size each chunk (part) should be nfile='2' nsegment='10' minchunk='1' # Location of remote files ready for pickup, no trailing slash REMOTE_MEDIA="***/downloads/Sync/" # Destination for remote media to be stored for further processing LOCAL_MEDIA="/mnt/user/Downloads/Seedbox/Sync" # Local processing directory files get moved to after sync PROC_MEDIA="/mnt/user/Downloads/Seedbox/Processing" # Test for local lockfile, exit if it exists BASE_NAME="$(basename "$0")" LOCK_FILE="/mnt/user/Downloads/Seedbox/Scripts/$BASE_NAME.lock" # Test for remote lockfile, exit if exists REMOTE_LOCK_FILE="***/scripts/post_process.sh.lock" # Fix permissions issue umask 002 # If a log file exists, rename it if [ -f $LOG_FILE ]; then mv $LOG_FILE $LOG_FILE.last fi echo "${0} Starting at $(date)" trap "rm -f ${LOCK_FILE}" SIGINT SIGTERM if [ -e "${LOCK_FILE}" ] then echo "${base_name} is running already." exit else ssh $USERNAME@$HOST "test -e $REMOTE_LOCK_FILE" if [ "$?" -eq "0" ]; then echo "Post Process is running on remote server, exiting..." exit fi touch "$LOCK_FILE" lftp -p "${PORT}" -u "${USERNAME},${PASS}" sftp://"${HOST}" << EOF set ftp:list-options -a set sftp:auto-confirm yes set pget:min-chunk-size ${minchunk} set pget:default-n ${nsegment} set mirror:use-pget-n ${nsegment} set mirror:parallel-transfer-count ${nfile} set mirror:parallel-directories yes set xfer:use-temp-file yes set xfer:temp-file-name *.lftp mirror -c -v --loop --Remove-source-dirs "${REMOTE_MEDIA}" "${LOCAL_MEDIA}" quit EOF echo "${0} Remote sync finished at $(date)" # Move sync'd files to processing directory rsync -av --progress --ignore-existing --remove-source-files --prune-empty-dirs -O \ --log-file=$LOG_FILE \ --log-file-format="%f - %n" \ ${LOCAL_MEDIA}/ \ ${PROC_MEDIA}/ # Clear Sync directory of empty folders and .DS_Store files find $LOCAL_MEDIA -name '.DS_Store' -type f -delete find $LOCAL_MEDIA -depth -type d -empty -exec rmdir "{}" \; mkdir -p $LOCAL_MEDIA rm -f "$LOCK_FILE" trap - SIGINT SIGTERM exit fi
September 16, 20205 yr On 3/28/2020 at 10:37 PM, Derek_ said: When i run Borg with a user.script - it performs its operations as root (as expected) and the dir/file ownership is root:root When i run and rsync copy with a user.script - it performs its operations as root (as expected) and the file ownership is with nobody:users. @Derek_ did you ever figure this out? I am having the same issue. When I run lftp, any folders/files it creates are root:root and i need it to be nobody:users. Thanks! Edited September 16, 20205 yr by cmarshall85
September 17, 20205 yr Author root:root vs nobody:users doesn't matter. Under either scenario, the permissions on files for access need to be either 666 or 777 Use the chmod command in the script if you can't get rsync to set permissions correctly
September 17, 20205 yr 1 hour ago, Alex.b said: /mnt/user/disk2/Nextcloud_backup Are you sure this is the actual path? That is a user share named disk2. I recommend not having a user share named the same as a disk. It will only lead to confusion. If this is indeed the correct path, maybe it was not what you had in mind. What did you have in mind?
September 17, 20205 yr 21 hours ago, Alex.b said: How can I keep for example last 10 folders ? Look here: https://stackoverflow.com/q/13868821/318765 Another solution with counting instead of timestamp: https://stackoverflow.com/q/4126869/318765 Edited September 18, 20205 yr by mgutt
September 20, 20205 yr Found a weird little bug that made for some interesting troubleshooting. I created a script with an exclamation point at the start. User scripts did not like this. Started throwing errors in the console. wouldn't allow me to delete so I removed from console. Lesson learnt, don't start scripts with a !
September 21, 20205 yr I have a problem where whenever an rsync script is ran via user scripts, Quote rsync -avu --chown=nobody:users --chmod=Du=rwx,Dgo=rwx,Fu=rw,Fog=rw --delete --stats --exclude=/cache/ -e "ssh -i /root/.ssh/NAS-rsync-key -T -o Compression=no -x" "[email protected]:/var/www/html" "/mnt/user/Backup/test" >> /home/nasbackuplogs/logs/$(date +"%Y%m%d")-test-backup.log When i test running this in the CLI it works fine, it sets both directories and files that are being backed up to the correct permissions for unraid, but whenever the same command runs via user scripts it for whatever reason sets the directory permissions to drwxrwx--- instead of drwxrwxrwx+, please advise?
September 21, 20205 yr 1 hour ago, je82 said: I have a problem where whenever an rsync script is ran via user scripts, When i test running this in the CLI it works fine, it sets both directories and files that are being backed up to the correct permissions for unraid, but whenever the same command runs via user scripts it for whatever reason sets the directory permissions to drwxrwx--- instead of drwxrwxrwx+, please advise? Try adding the following to the beginning of your command so it runs in a login shell: sudo -i -u root
September 21, 20205 yr 50 minutes ago, BRiT said: Might need to set the UMASK in your script. can you elaborate on how to do this properly?
September 21, 20205 yr 1 hour ago, je82 said: can you elaborate on how to do this properly? To set the umask to 0000 do the following on a line before your command: umask 0 Edited September 21, 20205 yr by JoeUnraidUser
September 22, 20205 yr Hi Love this plugin, have one issue, where only the first entry get the three icons (Log file, Download Log, and Delete Log) Ive inspected the dom, and the icons are there for the other lines, but display:none is applied Does any one know why, or is this a bug? Thanks Added to CA:March 30, 2018 Date Updated:August 21, 2020 Current Version:2020.08.22
September 22, 20205 yr 4 minutes ago, Matt_UK said: Hi Love this plugin, have one issue, where only the first entry get the three icons (Log file, Download Log, and Delete Log) Ive inspected the dom, and the icons are there for the other lines, but display:none is applied Does any one know why, or is this a bug? Thanks Added to CA:March 30, 2018 Date Updated:August 21, 2020 Current Version:2020.08.22 Until the script actually HAS a log file, the buttons are hidden. Or are you saying the scripts seem to be running on schedule, but still no buttons?
September 22, 20205 yr Author As long as the script has actually run, the log will always be present, if only saying that the script ran at such and such time.
September 23, 20205 yr On 9/21/2020 at 5:29 PM, Alex.b said: How can I access to /tmp/user.scripts/ to view full logs ? open unraid terminal (or ssh, etc) and use the "cd" command like so: cd /tmp/user/scripts/tmpScripts/xxx/ be sure to use capitals when necessary. If the script log is short, you can use the "cat" command to view directly in terminal window like so: cat /tmp/user.scripts/tmpScripts/xxx/xxx.txt (or if you used the "cd" command to navigate to the directory already, use:) cat xxx.txt If the log is too long to view its contents entirely in the terminal, you can copy the log to an easier to access location, such as a folder on the array, and open with a notepad app to view the whole log, like so: cp /tmp/user.scripts/tmpScripts/xxx/xxx.txt /insert/destination/path/here hope this helps
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.