[QPKG] RunLast

This is the best place for community developers to publish their genius work. Your Apps enrich the QNAP Turbo NAS.
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

rs1001 wrote: Thu May 06, 2021 3:36 pm Restarted twice and ALL my qpkg's are gone on the QTS "App Centre" interface!
It sounds like [/etc/config/qpkg.conf] is empty or incomplete. If so, you should be able to restore an older version from the automated backup QTS performs each Wednesday at 3:04am: viewtopic.php?p=643513#p643513
rs1001 wrote: Thu May 06, 2021 5:34 pm [/share/CACHEDEV1_DATA/.qpkg/COPS] # Usage: ./COPS.sh {start|stop|restart}
./COPS.sh start
COPS is disabled.
QTS won't allow you to 'start' a package that is disabled. So, the package must be enabled first:

Code: Select all

qpkg_service enable COPS
... but, you'll need to solve the empty qpkg.conf problem first.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
DeeJaWue
New here
Posts: 4
Joined: Wed Aug 04, 2021 5:40 pm

Re: [QPKG] RunLast

Post by DeeJaWue »

Hello,

i have another problem.

I wrote an .sh script to start two Docker containers with specific Options.
The Script works, when ist start it with bash in ssh.

RunLast sent this log:
RunLast (20210328)
[Wed Aug 4 11:32:43 CEST 2021] begin "start" scripts ...
[Wed Aug 4 11:32:43 CEST 2021] -> execute: "'/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh'" ...
[Wed Aug 4 11:32:43 CEST 2021] => exitcode: (0)
[Wed Aug 4 11:32:43 CEST 2021] => stderr: "/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh: line 2: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh: line 3: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh: line 4: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh: line 7: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh: line 8: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/Docker_start.sh: line 10: docker: command not found"
[Wed Aug 4 11:32:43 CEST 2021] end "start" scripts
────────────────────────────────────────────────────────

So it seems, that the script works, but RunLast call the script befor Qnap starts the Docker enviroment.

What can i do, that RunLast Call the script after Docker/ Container Station run?
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

Hi and welcome to the forum. :)
DeeJaWue wrote: Wed Aug 04, 2021 5:45 pm So it seems, that the script works, but RunLast call the script befor Qnap starts the Docker enviroment.

What can i do, that RunLast Call the script after Docker/ Container Station run?
Sounds like the same problem as mentioned here: viewtopic.php?f=25&t=162258

It appears QTS is starting containers very late in the boot process. So-late, they are not up-and-running by the time RunLast executes. :(

You may need to include a delay in your script that waits until the 'docker' command can be seen before attempting to use it.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
Don
Guru
Posts: 12289
Joined: Thu Jan 03, 2008 4:56 am
Location: Long Island, New York

Re: [QPKG] RunLast

Post by Don »

Isn’t docker a qpkg? If so wouldn’t using sortmyqpkgs work?
Use the forum search feature before posting.

Use RAID and external backups. RAID will protect you from disk failure, keep your system running, and data accessible while the disk is replaced, and the RAID rebuilt. Backups will allow you to recover data that is lost or corrupted, or from system failure. One does not replace the other.

NAS: TVS-882BR | F/W: 5.0.1.2346 | 40GB | 2 x 1TB M.2 SATA RAID 1 (System/VMs) | 3 x 1TB M.2 NMVe QM2-4P-384A RAID 5 (cache) | 5 x 14TB Exos HDD RAID 6 (Data) | 1 x Blu-ray
NAS: TVS-h674 | F/W: 5.0.1.2376 | 16GB | 3 x 18TB RAID 5
Apps: DNSMasq, PLEX, iDrive, QVPN, QLMS, MP3fs, HBS3, Entware, DLstation, VS, +
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

Don wrote: Thu Aug 05, 2021 10:49 am Isn’t docker a qpkg? If so wouldn’t using sortmyqpkgs work?
Yes, Container Station is a QPKG, and it's being sorted correctly. RunLast does a similar order re-shuffling operation to SortMyQPKGs, except that it only ensures RunLast is placed last in [/etc/config/qpkg.conf].

The problem appears to be that QTS launches Container Station, which then releases control back to QTS before Container Station has finished starting its containers. Container Station isn't waiting for all containers to load, so it ends-up doing this in-parallel while loading any QPKGs listed after Container Station in [qpkg.conf]. :(

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
DeeJaWue
New here
Posts: 4
Joined: Wed Aug 04, 2021 5:40 pm

Re: [QPKG] RunLast

Post by DeeJaWue »

Hello @all,

an new Update:
I wrote a little Sleep.sh (5min), that start first in RunLast, after that the normal Docker_start.sh started.

The Log shows that:

Code: Select all

RunLast (20210328)
[Fri Aug  6 12:45:38 CEST 2021] begin "start" scripts ...
[Fri Aug  6 12:45:38 CEST 2021] -> execute: "'/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/01_SLEEP.sh'" ...
[Fri Aug  6 12:50:38 CEST 2021] => exitcode: (0)
[Fri Aug  6 12:50:38 CEST 2021] => stdout: "Sleep Script Start
Sleep Script end"
[Fri Aug  6 12:50:38 CEST 2021] => stderr: ""
[Fri Aug  6 12:50:38 CEST 2021] -> execute: "'/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh'" ...
[Fri Aug  6 12:50:38 CEST 2021] => exitcode: (0)
[Fri Aug  6 12:50:38 CEST 2021] => stdout: "Docker Script startet
Docker Script beendet"
[Fri Aug  6 12:50:38 CEST 2021] => stderr: "/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh: line 4: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh: line 5: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh: line 6: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh: line 9: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh: line 10: docker: command not found
/share/CACHEDEV1_DATA/.qpkg/RunLast/scripts/02_Docker_start.sh: line 12: docker: command not found"
[Fri Aug  6 12:50:38 CEST 2021] end "start" scripts
Or do I have an error in this file?
02_Docker_start.sh

Code: Select all

#!/bin/bash
echo Docker Script startet
# Proof, that Container does't rund and remove it
docker ps -a --filter "name=HomeAssistant" | grep -q . && docker stop HomeAssistant && docker rm -fv HomeAssistant
# Get newest version
docker pull homeassistant/home-assistant:latest
#Run Container with specific commands
docker run --name HomeAssistant --net=host --privileged -itd -v /share/Container/HomeAssistant:/config -e TZ=Europe/Berlin --device /dev/ttyACM0 homeassistant/home-assistant:latest


#Same doing like HomeAssistant
docker ps -a --filter "name=DDNS_Updater" | grep -q . && docker stop DDNS_Updater && docker rm -fv DDNS_Updater
docker pull qmcgaw/ddns-updater

docker run --name DDNS_Updater -d -p 8000:8000/tcp -v /share/Container/DDNSUpdater/data:/updater/data qmcgaw/ddns-updater

echo Docker Script beendet
exit 0
Because the Docker_Start Scripts runs, if i run it in ssh via "bash path....02_Docker_start.sh".
Or is "#!/bin/bash" the wrong interpreter?
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

Your script looks fine (including the hashbang line). Image

Best-guess: $PATH is being modified after RunLast has started, most likely by Container Station. Which means RunLast won't see the updated $PATH variable, and means the 'docker' command can't be run without specifying the absolute path to the 'docker' executable.

A workaround you could try is to modify your $PATH to include the location of the 'docker' command near the start of your script. Check this with:

Code: Select all

which docker
Then re-assign $PATH near the beginning of your [02_Docker_start.sh] script and prefix it with the path shown by the previous command. Please advise if you require assistance with this bit. :)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
daNutz
Getting the hang of things
Posts: 72
Joined: Mon May 07, 2012 10:04 pm
Location: London, UK

Re: [QPKG] RunLast

Post by daNutz »

Hi, im getting the following rreported upon boot:

Code: Select all

[RunLast] your SortMyQPKGs version is incompatible with this package
Any ideas?
TS-1079Pro - 30TB - RAID 6 - FW: 4.3.6.2232 - MultiMedia
TS-453 Pro - 12TB - RAID 5 - OS: Ubuntu Server 22.04.2 / Docker
SelfHosted
NAS Migration Compatibility

ImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
Don
Guru
Posts: 12289
Joined: Thu Jan 03, 2008 4:56 am
Location: Long Island, New York

Re: [QPKG] RunLast

Post by Don »

daNutz wrote: Sat Aug 07, 2021 8:29 pm Hi, im getting the following rreported upon boot:

Code: Select all

[RunLast] your SortMyQPKGs version is incompatible with this package
Any ideas?
What version of each are you running (please don't say the latest)?
Use the forum search feature before posting.

Use RAID and external backups. RAID will protect you from disk failure, keep your system running, and data accessible while the disk is replaced, and the RAID rebuilt. Backups will allow you to recover data that is lost or corrupted, or from system failure. One does not replace the other.

NAS: TVS-882BR | F/W: 5.0.1.2346 | 40GB | 2 x 1TB M.2 SATA RAID 1 (System/VMs) | 3 x 1TB M.2 NMVe QM2-4P-384A RAID 5 (cache) | 5 x 14TB Exos HDD RAID 6 (Data) | 1 x Blu-ray
NAS: TVS-h674 | F/W: 5.0.1.2376 | 16GB | 3 x 18TB RAID 5
Apps: DNSMasq, PLEX, iDrive, QVPN, QLMS, MP3fs, HBS3, Entware, DLstation, VS, +
User avatar
daNutz
Getting the hang of things
Posts: 72
Joined: Mon May 07, 2012 10:04 pm
Location: London, UK

Re: [QPKG] RunLast

Post by daNutz »

Don wrote: Sun Aug 08, 2021 2:37 am
daNutz wrote: Sat Aug 07, 2021 8:29 pm Hi, im getting the following rreported upon boot:

Code: Select all

[RunLast] your SortMyQPKGs version is incompatible with this package
Any ideas?
What version of each are you running (please don't say the latest)?
RunLast = 210328
SortMyQPKGs = 210708c
TS-1079Pro - 30TB - RAID 6 - FW: 4.3.6.2232 - MultiMedia
TS-453 Pro - 12TB - RAID 5 - OS: Ubuntu Server 22.04.2 / Docker
SelfHosted
NAS Migration Compatibility

ImageImageImageImageImageImageImageImageImageImageImageImageImage
DeeJaWue
New here
Posts: 4
Joined: Wed Aug 04, 2021 5:40 pm

Re: [QPKG] RunLast

Post by DeeJaWue »

Hello OneCD,

yes i need help :D

I tried this one:

Code: Select all

#!/bin/bash
echo Docker Script startet

#Set PATH to Docker
export PATH=$PATH:/share/CACHEDEV1_DATA/.qpkg/container-station/bin/docker

docker ps -a --filter "name=HomeAssistant" | grep -q . && docker stop HomeAssistant && docker rm -fv HomeAssistant
docker pull homeassistant/home-assistant:latest
docker run --name HomeAssistant --net=host --privileged -itd -v /share/Container/HomeAssistant:/config -e TZ=Europe/Berlin --device /dev/ttyACM0 homeassistant/home-assistant:latest


docker ps -a --filter "name=DDNS_Updater" | grep -q . && docker stop DDNS_Updater && docker rm -fv DDNS_Updater
docker pull qmcgaw/ddns-updater

docker run --name DDNS_Updater -d -p 8000:8000/tcp -v /share/Container/DDNSUpdater/data:/updater/data qmcgaw/ddns-updater

echo Docker Script beendet
exit 0
But it doesn't work...

What is the correct way to define the Path to docker?

Thanks a lot!!
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

daNutz wrote: Sun Aug 08, 2021 8:48 pm RunLast = 210328
SortMyQPKGs = 210708c
Oops! I see the problem. RunLast checks its own version against that of SortMyQPKGs. It does this by evaluating both versions as integers. When I released that last SortMyQPKGs, I used a 'c' character - which then breaks the integer evaluation in RunLast. :oops:

I'll update RunLast so it only checks the datecode part of the version number. This new version will be released shortly.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

A new RunLast version (210809) has just been released that should stop this message being shown:
[RunLast] your SortMyQPKGs version is incompatible with this package
... when you also have SortMyQPKGs 210708c installed. :geek:

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
daNutz
Getting the hang of things
Posts: 72
Joined: Mon May 07, 2012 10:04 pm
Location: London, UK

Re: [QPKG] RunLast

Post by daNutz »

OneCD wrote: Mon Aug 09, 2021 2:36 am A new RunLast version (210809) has just been released that should stop this message being shown:
[RunLast] your SortMyQPKGs version is incompatible with this package
... when you also have SortMyQPKGs 210708c installed. :geek:
thanks, ive updated to it and will test now, im assuming it was just are flag and it didnt operationally impact RunLast?
Last edited by daNutz on Mon Aug 09, 2021 3:46 am, edited 1 time in total.
TS-1079Pro - 30TB - RAID 6 - FW: 4.3.6.2232 - MultiMedia
TS-453 Pro - 12TB - RAID 5 - OS: Ubuntu Server 22.04.2 / Docker
SelfHosted
NAS Migration Compatibility

ImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
OneCD
Guru
Posts: 12010
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [QPKG] RunLast

Post by OneCD »

DeeJaWue wrote: Mon Aug 09, 2021 12:40 am

Code: Select all

#Set PATH to Docker
export PATH=$PATH:/share/CACHEDEV1_DATA/.qpkg/container-station/bin/docker
What is the correct way to define the Path to docker?
Your $PATH should only contain directory names - not the name of the executable that will be searched-for in $PATH. Try this:

Code: Select all

#Set PATH to Docker
export PATH=$PATH:/share/CACHEDEV1_DATA/.qpkg/container-station/bin
But, you'll also need to ensure 'docker' is visible before attempting to run it. Maybe add a loop like this to your script:

Code: Select all

for ((waitseconds=0; waitseconds<=300; waitseconds++)); do
    (which docker > /dev/null) && break || sleep 1
done

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Post Reply

Return to “Community Apps”