Phoenix Down Posted August 13, 2020 Share Posted August 13, 2020 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. Quote Link to comment
l4t3b0 Posted August 15, 2020 Share Posted August 15, 2020 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. Quote Link to comment
l4t3b0 Posted August 15, 2020 Share Posted August 15, 2020 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. Quote Link to comment
l4t3b0 Posted August 15, 2020 Share Posted August 15, 2020 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? Quote Link to comment
mihcox Posted August 15, 2020 Share Posted August 15, 2020 (edited) 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, 2020 by mihcox Quote Link to comment
mgutt Posted August 15, 2020 Share Posted August 15, 2020 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. Quote Link to comment
mihcox Posted August 15, 2020 Share Posted August 15, 2020 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. Quote Link to comment
mgutt Posted August 15, 2020 Share Posted August 15, 2020 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). Quote Link to comment
mihcox Posted August 15, 2020 Share Posted August 15, 2020 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! Quote Link to comment
Marcel_Costa Posted August 24, 2020 Share Posted August 24, 2020 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 ! Quote Link to comment
Cpt. Chaz Posted September 15, 2020 Share Posted September 15, 2020 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. 1 Quote Link to comment
cmarshall85 Posted September 16, 2020 Share Posted September 16, 2020 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 Quote Link to comment
cmarshall85 Posted September 16, 2020 Share Posted September 16, 2020 (edited) 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, 2020 by cmarshall85 Quote Link to comment
Squid Posted September 17, 2020 Author Share Posted September 17, 2020 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 Quote Link to comment
trurl Posted September 17, 2020 Share Posted September 17, 2020 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? Quote Link to comment
mgutt Posted September 17, 2020 Share Posted September 17, 2020 (edited) 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, 2020 by mgutt Quote Link to comment
sauso Posted September 20, 2020 Share Posted September 20, 2020 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 ! Quote Link to comment
je82 Posted September 21, 2020 Share Posted September 21, 2020 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? Quote Link to comment
JoeUnraidUser Posted September 21, 2020 Share Posted September 21, 2020 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 Quote Link to comment
je82 Posted September 21, 2020 Share Posted September 21, 2020 50 minutes ago, BRiT said: Might need to set the UMASK in your script. can you elaborate on how to do this properly? Quote Link to comment
JoeUnraidUser Posted September 21, 2020 Share Posted September 21, 2020 (edited) 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, 2020 by JoeUnraidUser Quote Link to comment
Matt_UK Posted September 22, 2020 Share Posted September 22, 2020 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 Quote Link to comment
JonathanM Posted September 22, 2020 Share Posted September 22, 2020 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? Quote Link to comment
Squid Posted September 22, 2020 Author Share Posted September 22, 2020 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. Quote Link to comment
Cpt. Chaz Posted September 23, 2020 Share Posted September 23, 2020 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 Quote Link to comment
Recommended Posts
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.