[SCRIPT] create-autorun.sh

Introduce yourself to us and other members here, or share your own product reviews, suggestions, and tips and tricks of using QNAP products.
Post Reply
RichJacot
Starting out
Posts: 38
Joined: Fri Apr 24, 2020 9:16 pm

Re: [SCRIPT] create-autorun.sh

Post by RichJacot »

Yes, it has remained through all of my reboots. hmmm... It shouldn't?

[/share/CACHEDEV1_DATA/.system/autorun] # cd /
[/] # ll
total 4.0K
drwxr-xr-x 22 admin administrators 540 2020-05-06 17:27 ./
drwxr-xr-x 22 admin administrators 540 2020-05-06 17:27 ../
-rw-r--r-- 1 admin administrators 135 2020-05-06 17:25 1
drwxr-xr-x 2 admin administrators 2.1K 2020-05-06 17:22 bin/
drwxr-xr-x 15 admin administrators 21K 2020-05-06 17:35 dev/
drwxr-xr-x 34 admin administrators 3.2K 2020-05-06 17:35 etc/
drwxr-xr-x 2 admin administrators 40 2020-05-06 17:22 flashfs_tmp/
lrwxrwxrwx 1 admin administrators 13 2020-05-06 17:22 hd_root_tmp -> /mnt/HDA_ROOT/
drwxr-xr-x 4 admin administrators 80 2020-04-09 15:57 home/
drwxr-xr-x 7 admin administrators 4.4K 2020-05-06 17:23 lib/
lrwxrwxrwx 1 admin administrators 3 2020-05-06 12:21 lib64 -> lib/
lrwxrwxrwx 1 admin administrators 11 2020-05-06 12:21 linuxrc -> bin/busybox*
drwx------ 2 admin administrators 40 2020-04-09 15:58 lost+found/
drwxr-xr-x 13 admin administrators 280 2020-05-06 17:24 mnt/
drwxr-xr-x 2 admin administrators 40 2020-05-06 12:21 new_root/
drwxr-sr-x 2 admin administrators 200 2020-05-06 17:27 opt/
lrwxrwxrwx 1 admin administrators 19 2020-05-06 12:21 php.ini -> /etc/config/php.ini
drwxrwxrwx 2 admin administrators 40 2020-05-06 17:27 plex.transcoding.tmp/
dr-xr-xr-x 340 admin administrators 0 2020-05-06 12:21 proc/
drwxr-xr-x 2 admin administrators 240 2020-05-06 17:25 root/
drwxr-xr-x 2 admin administrators 40 2020-05-06 17:25 rpc/
drwxr-xr-x 2 admin administrators 9.6K 2020-05-06 17:26 sbin/
drwxrwxrwt 31 admin administrators 800 2020-05-06 17:25 share/
dr-xr-xr-x 12 admin administrators 0 2020-05-06 11:21 sys/
drwxrwxrwx 18 admin administrators 2.5K 2020-05-06 18:04 tmp/
drwxr-xr-x 9 admin administrators 200 2020-04-09 14:50 usr/
drwxr-xr-x 16 admin administrators 740 2020-05-06 18:04 var/
[/] #
TVS-672N - 32GB - 4.5.1.1594 - Static volume - RAID5 - 6 x 10TB Ironwolf --- Thick Volume RAID1 - 2 x 500GB M.2 SSD - CT500P1SSD8 in a QM2-2P10G1TA
TS-453B - 16GB - 4.5.1.1540 - Static volume - RAID5 - 4 x 4TB WD Red
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

RichJacot wrote: Thu May 07, 2020 7:05 am Yes, it has remained through all of my reboots. hmmm... It shouldn't?
Only that yours would be the first. QTS is an embedded OS. It's not like a regular Linux desktop or server distro. It has a preset and read-only filesystem image which is loaded on boot and expanded into RAM. So, user-created directories from the root filesystem are not saved or restored.

How are you checking your new tmpfs has been created?

What's the output from:

Code: Select all

df
... ?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
RichJacot
Starting out
Posts: 38
Joined: Fri Apr 24, 2020 9:16 pm

Re: [SCRIPT] create-autorun.sh

Post by RichJacot »

Yes, df. Let me remove my script and reboot to see if it stays. I haven't looked without my script in place.

I'll send you the outputs shortly.

Sent from my SM-N975U using Tapatalk

TVS-672N - 32GB - 4.5.1.1594 - Static volume - RAID5 - 6 x 10TB Ironwolf --- Thick Volume RAID1 - 2 x 500GB M.2 SSD - CT500P1SSD8 in a QM2-2P10G1TA
TS-453B - 16GB - 4.5.1.1540 - Static volume - RAID5 - 4 x 4TB WD Red
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

I wonder if it's being created by something else after autorun.sh is executed?

Try your script with these mods:

Code: Select all

#!/bin/bash
TARGET_PATH=/plex.transcoding.tmp
[[ ! -d $TARGET_PATH ]] && { mkdir -p $TARGET_PATH; echo "created target" ;} || echo "target already exists"
/bin/mount -t tmpfs -o size=16G tmpfs $TARGET_PATH; echo "a:$?"
/bin/touch /share/CACHEDEV1_DATA/.system/autorun/scripts/plxran; echo "b:$?"

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
RichJacot
Starting out
Posts: 38
Joined: Fri Apr 24, 2020 9:16 pm

Re: [SCRIPT] create-autorun.sh

Post by RichJacot »

Sorry, to many users now. I'm going to have to do this in the morning.

Sent from my SM-N975U using Tapatalk

TVS-672N - 32GB - 4.5.1.1594 - Static volume - RAID5 - 6 x 10TB Ironwolf --- Thick Volume RAID1 - 2 x 500GB M.2 SSD - CT500P1SSD8 in a QM2-2P10G1TA
TS-453B - 16GB - 4.5.1.1540 - Static volume - RAID5 - 4 x 4TB WD Red
RichJacot
Starting out
Posts: 38
Joined: Fri Apr 24, 2020 9:16 pm

Re: [SCRIPT] create-autorun.sh

Post by RichJacot »

Okay, I removed my script and sure enough my /plex.transcoding.tmp wasn't there. Interesting but I hadn't rebooted without my script in place and every time I looked my /plex.transcoding.tmp dir was there.

I made the changes you suggested and now it appears to be working perfectly now. /plex.transcoding.tmp is there, I can see it with df and below is the autorun.log

[/share/CACHEDEV1_DATA/.system/autorun/scripts] # cat /var/log/autorun.log
Thu May 7 06:27:14 CDT 2020 ----- running autorun.sh -----
Thu May 7 06:27:14 CDT 2020 - /share/CACHEDEV1_DATA/.system/autorun/scripts/PlexTranscodeRAMDrive.sh
created target
a:0
b:0
[/share/CACHEDEV1_DATA/.system/autorun/scripts] #

I ran a couple of streams earlier this morning that needed to be transcoded and I could watch /plex.transcoding.tmp grow.

Thank you Sir!
TVS-672N - 32GB - 4.5.1.1594 - Static volume - RAID5 - 6 x 10TB Ironwolf --- Thick Volume RAID1 - 2 x 500GB M.2 SSD - CT500P1SSD8 in a QM2-2P10G1TA
TS-453B - 16GB - 4.5.1.1540 - Static volume - RAID5 - 4 x 4TB WD Red
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

RichJacot wrote: Thu May 07, 2020 7:48 pm I ran a couple of streams earlier this morning that needed to be transcoded and I could watch /plex.transcoding.tmp grow.
Good work. :D

So, your script can now be reduced to:

Code: Select all

#!/bin/bash
TARGET_PATH=/plex.transcoding.tmp
[[ ! -d $TARGET_PATH ]] && mkdir -p $TARGET_PATH
/bin/mount -t tmpfs -o size=16G tmpfs $TARGET_PATH

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
RichJacot
Starting out
Posts: 38
Joined: Fri Apr 24, 2020 9:16 pm

Re: [SCRIPT] create-autorun.sh

Post by RichJacot »

Roger that and thanks again!
TVS-672N - 32GB - 4.5.1.1594 - Static volume - RAID5 - 6 x 10TB Ironwolf --- Thick Volume RAID1 - 2 x 500GB M.2 SSD - CT500P1SSD8 in a QM2-2P10G1TA
TS-453B - 16GB - 4.5.1.1540 - Static volume - RAID5 - 4 x 4TB WD Red
MikeLagit
Easy as a breeze
Posts: 332
Joined: Fri Mar 22, 2013 11:40 pm

Re: [SCRIPT] create-autorun.sh

Post by MikeLagit »

I'm using Entware with mlocate installed for indexing files for fast finds. I need to prune out the snapshots directory as it creates a ton of duplicates I don't care about. If I edit the /etc/updatedb.conf, it is overwritten at reboot. I don't see a way to implement a permanent version of the config file (correct me if I am wrong), so I resorted to this supercool tool from OneCD. I have it setup, but it's still getting overwritten at boot. Is this an ordering problem? I tested the script below and it adds the prunepath when run it manually, I just cant get it to stick after a reboot. Please see below and let me know if you have suggestions.
[~] # cat /opt/etc/updatedb.conf
PRUNENAMES="/.AppleDB/.AppleDouble/.AppleDesktop/:2eDS_Store/Network Trash Folder/Temporary Items/TheVolumeSettingsFolder/.@__thumb/.@__desc/:2e*/.@__qini/.Qsync/.@upload_cache/.qsync/.qsync_sn/.@qsys/.streams/.digest/.*/"
The above output doesn't have my additional line and should look like this:
[~] # cat /opt/etc/updatedb.conf
PRUNENAMES="/.AppleDB/.AppleDouble/.AppleDesktop/:2eDS_Store/Network Trash Folder/Temporary Items/TheVolumeSettingsFolder/.@__thumb/.@__desc/:2e*/.@__qini/.Qsync/.@upload_cache/.qsync/.qsync_sn/.@qsys/.streams/.digest/.*/"
PRUNEPATHS="/mnt/snapshot"
If I look at my logs it says the script was run:
[~] # cat /var/log/autorun.log
Thu May 14 12:15:02 CDT 2020 ----- running autorun.sh -----
Thu May 14 12:15:02 CDT 2020 - /share/CACHEDEV1_DATA/.system/autorun/scripts/010-mlocate.sh
Running it manually does add the prunepaths to the /opt/etc/updatedb.conf (tested it manually to make sure script is valid and executable).
[~] # cat /share/CACHEDEV1_DATA/.system/autorun/scripts/010-mlocate.sh
#!/bin/bash
echo "PRUNEPATHS=\"/mnt/snapshot\"" >> /opt/etc/updatedb.conf
Please let me know what I could be doing wrong. Is this a case for the RunLast qpkg?
Last edited by MikeLagit on Sun Dec 13, 2020 6:59 am, edited 1 time in total.
Model: TVS-872XT 16GB
Model: TS-877-1700 16GB
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

MikeLagit wrote: Fri May 15, 2020 1:33 am Is this a case for the RunLast qpkg?
RunLast would be one way to do it. But the problem is that Entware can take some time to complete startup reintegration while the NAS is booting. RunLast may execute your script while Entware is unavailable. Which means you would need to introduce a wait-and-check poll to test for Entware availability over about a 10 minute period. This works but is not ideal.

A neater solution may be to use the init.d system included with Entware. This is just like the ancient init.d system included with QTS, but works with Entware installed IPKGs.

So, your script would be placed into [/opt/etc/init.d] and renamed to start with an 'S'. It will then run when Entware's startup reintegration is complete.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
MikeLagit
Easy as a breeze
Posts: 332
Joined: Fri Mar 22, 2013 11:40 pm

Re: [SCRIPT] create-autorun.sh

Post by MikeLagit »

I don't see any other S scripts in that dir. Is that the correct location? You're saying I can just move that script into that location and it should execute it?
[/opt/etc/init.d] # ll
total 16K
drwxr-xr-x 2 admin administrators 4.0K 2018-06-07 19:09 ./
drwxr-xr-x 6 admin administrators 4.0K 2020-04-28 17:03 ../
-rw-r--r-- 1 admin administrators 2.8K 2018-03-12 14:22 rc.func
-rwxr-xr-x 1 admin administrators 966 2018-03-12 14:22 rc.unslung*
[/opt/etc/init.d] #
Model: TVS-872XT 16GB
Model: TS-877-1700 16GB
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

MikeLagit wrote: Fri May 15, 2020 5:32 am I don't see any other S scripts in that dir. Is that the correct location?
Which only means there are no currently installed IPKGs with init scripts. The only ones requiring init scripts are daemons.
MikeLagit wrote: Fri May 15, 2020 5:32 am You're saying I can just move that script into that location and it should execute it?
That's the theory. ;)

Try it and see. Add your script to that location, and rename it to prefix an 'S'. Then 'stop' - wait - then 'start' the Entware QPKG in your App Center (no need to reboot the NAS). This will run the same package reintegration process as when QTS is booting. When this completes, your script should be executed.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
MikeLagit
Easy as a breeze
Posts: 332
Joined: Fri Mar 22, 2013 11:40 pm

Re: [SCRIPT] create-autorun.sh

Post by MikeLagit »

Worked like a charm! Thanks you for the help!!
Model: TVS-872XT 16GB
Model: TS-877-1700 16GB
User avatar
Qmann
Easy as a breeze
Posts: 302
Joined: Mon Jun 08, 2020 8:09 am
Location: USA

Re: [SCRIPT] create-autorun.sh

Post by Qmann »

I need to figure out the best way to sticky permissions and group on /dev/dri. Would autostart.sh be the best place to do it? Here is the issue:

For Plex hardware transcoding, I need the /dev/dri to be in the video group, and readable by the plex user which is in docker. I have the /dev/dri passed to the docker and no problem getting it to work, but after each reboot /dev/dri is set back to admin:administrators. After each reboot, I need to issue these commands to get hw transcode going again:

chmod ug+rwX -R /dev/dri
chgrp -R video /dev/dri
docker restart linuxserver/plex (so it picks up the changes)

What is the best fix here? autostart.sh would get things changed on the system, but somehow it would have to come before docker get started to avoid another restart.

SMP:
* New order *
(01) (A) Entware
(02) (A) NvKernelDriver
(03) (A) netmgr
(04) (A) NodeJS
(05) (A) QJDK8
(06) (A) container-station
(07) (A) Qapache
(08) (A) MySQL8
(09) (A) MultimediaConsole
(10) (A) HybridBackup
(11) (Φ) helpdesk
(12) (Φ) Qboost
(13) (Φ) ResourceMonitor
(14) (Φ) QKVM
(15) (Φ) PlexPy
(16) (Φ) QSubSonic
(17) (Φ) NotificationCenter
(18) (Φ) SSDLaboratory
(19) (Φ) SecurityCounselor
(20) (Φ) browser-station
(21) (Φ) iPerf3
(22) (Φ) LicenseCenter
(23) (Φ) QcloudSSLCertificate
(24) (Ω) MalwareRemover
(25) (Ω) SortMyQPKGs
Thanks,
Qmann
Last edited by Qmann on Tue Oct 06, 2020 1:10 pm, edited 1 time in total.
Model: TVS-872XT 64GB (Crucial 64GB Kit CT2K32G4SFD8266)
2 x 1TB XPG 1TB NVMe (ASX8200PNP-1TT-C) [RAID-1]
5 x 16TB EXOS [RAID-5]
Borg Backup running to an offisite pi, AND to the local TS-569L
Model: TS-569L Borg server for backups
6 x 8TB Ironwolf [RAID-5]
Qotom-Q355G4 Fanless Mini Micro PC running pSense in front of everything
haproxy for anything inside the LAN
User avatar
OneCD
Guru
Posts: 12146
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

Qmann wrote: Tue Oct 06, 2020 12:53 pm What is the best fix here? autostart.sh would get things changed on the system, but somehow it would have to come before docker get started to avoid another restart.
This may work, if 'autorun.sh' is executed before Container Station. Try it and see. ;)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Post Reply

Return to “Users' Corner”