[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
teh_niemer
Starting out
Posts: 17
Joined: Sat Nov 04, 2017 7:24 am

Re: [SCRIPT] create-autorun.sh

Post by teh_niemer »

I found the issue, erroneous carriage return on one of the lines. All is well now.
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

Good work. :geek:

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
sthones
New here
Posts: 8
Joined: Mon Oct 22, 2018 11:49 pm

Re: [SCRIPT] create-autorun.sh

Post by sthones »

I have been trying to run this on TS-231P2, but fail with:
* script version : 181102
* NAS model : TS-X31P2 (TS-231P2)
* QTS version : 4.3.6 #20190328
* default volume : /share/CACHEDEV1_DATA

√ DOM partition found : /dev/mtd6
X Unable to mount (ext4) DOM partition (/dev/mmcblk0p7)! Error: [mount: mounting ubi2:config on /tmp/create-autorun.HjebKJ failed: No such device]

X autorun.sh creation failed!
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

sthones wrote: Sat Apr 27, 2019 10:38 pm I have been trying to run this on TS-231P2, but fail with:
Can you please run this and post the output?

Code: Select all

cat /etc/platform.conf

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
sthones
New here
Posts: 8
Joined: Mon Oct 22, 2018 11:49 pm

Re: [SCRIPT] create-autorun.sh

Post by sthones »

OneCD wrote: Sun Apr 28, 2019 3:59 am
sthones wrote: Sat Apr 27, 2019 10:38 pm I have been trying to run this on TS-231P2, but fail with:
Can you please run this and post the output?

Code: Select all

cat /etc/platform.conf
here is the content:
Platform = ARM_AL
SUID = 8300974ab1c56c01e84068778f78831f

[DIMM 1]
valid = 1
channel_id = 1
slot_id = 1
slot_addr = 0x52
type = 11
speed = 5
module_type = 3
ecc = 0
size = 4096
manufaturer = Transcend Information

[FIRMWARE STORAGE]
DEVICE_NODE = /dev/mtd
FS_TYPE = ubifs
UPDATE_TMP_PARTITION = 5
FS_ACTIVE_PARTITION = 3
FS_RECOVERY_PID = -1

[CONFIG STORAGE]
DEVICE_NODE = /dev/mtd
FS_TYPE = ubifs
FS_ACTIVE_PARTITION = 6

[MISC]
DISPLAY_NAME = TS-231P2
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

And this one please?

Code: Select all

blkid
We'll then try a manual DOM mount (I'll provide the commands to use), so we can see where this is going wrong. :'

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
sthones
New here
Posts: 8
Joined: Mon Oct 22, 2018 11:49 pm

Re: [SCRIPT] create-autorun.sh

Post by sthones »

OneCD wrote: Mon Apr 29, 2019 3:48 am And this one please?

Code: Select all

blkid
We'll then try a manual DOM mount (I'll provide the commands to use), so we can see where this is going wrong. :'
here you go:

Code: Select all

# blkid
/dev/dm-0: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/dm-8: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/dm-7: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/dm-6: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/dm-5: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/dm-4: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/md322: UUID="9690300c-9ba0-4e96-8195-7947f89d2a0c" TYPE="swap"
/dev/md256: UUID="b4bdf861-5597-418b-9238-97594f6027e3" TYPE="swap"
/dev/md13: UUID="170e69ff-71ac-4f94-85f6-331a776335c3" TYPE="ext3"
/dev/md9: UUID="6a443ea9-9061-4592-b4c1-d2c3d65bfd33" TYPE="ext4"
/dev/sdb5: UUID="9690300c-9ba0-4e96-8195-7947f89d2a0c" TYPE="swap"
/dev/sdb4: UUID="170e69ff-71ac-4f94-85f6-331a776335c3" TYPE="ext3"
/dev/sdb2: UUID="b4bdf861-5597-418b-9238-97594f6027e3" TYPE="swap"
/dev/sdb1: UUID="6a443ea9-9061-4592-b4c1-d2c3d65bfd33" TYPE="ext4"
/dev/sda5: UUID="9690300c-9ba0-4e96-8195-7947f89d2a0c" TYPE="swap"
/dev/sda4: UUID="170e69ff-71ac-4f94-85f6-331a776335c3" TYPE="ext3"
/dev/sda2: UUID="b4bdf861-5597-418b-9238-97594f6027e3" TYPE="swap"
/dev/sda1: UUID="6a443ea9-9061-4592-b4c1-d2c3d65bfd33" TYPE="ext4"
/dev/mapper/cachedev1: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/mapper/vg1-lv1: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/mapper/vg1-tp1: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/mapper/vg1-tp1-tpool: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/mapper/vg1-tp1_tierdata_2: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
/dev/mapper/vg1-tp1_tierdata_2_fcorig: LABEL="Data" UUID="3debdf22-03de-4258-8583-4de0b98464e6" TYPE="ext4"
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

The correct sequence for your model should be:

Code: Select all

mkdir /tmp/dom.tmp
ubiattach -m 6 -d 2 
mount -vt ubifs ubi2:config /tmp/dom.tmp
Please try these commands in order.

Some QNAP models report UBIFS for the DOM filesystem but really use EXT4, so if the previous 'mount' command failed, try:

Code: Select all

mount -vt ext4 /dev/mmcblk0p7 /tmp/dom.tmp
You should see failures for both mount commands, as they have already been tried in the [create-autorun.sh] script. Can you please run them anyway and post the results back here? Running them manually will provide a bit more information.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
sthones
New here
Posts: 8
Joined: Mon Oct 22, 2018 11:49 pm

Re: [SCRIPT] create-autorun.sh

Post by sthones »

this explains what's going wrong:

Code: Select all

# mkdir /tmp/dom.tmp
# ubiattach -m 6 -d 2
BusyBox v1.28.1 (2018-02-15 14:34:02 CET) multi-call binary.

Usage: ubiattach -m MTD_NUM [-d UBI_NUM] [-O VID_HDR_OFF] UBI_CTRL_DEV

Attach MTD device to UBI

        -m MTD_NUM      MTD device number to attach
        -d UBI_NUM      UBI device number to assign
        -O VID_HDR_OFF  VID header offset
✗(1) # mount -vt ubifs ubi2:config /tmp/dom.tmp
mount: mounting ubi2:config on /tmp/dom.tmp failed: No such device
✗(255) # which ubiattach
/share/linux/tools/busybox/ubiattach
I have busybox installed, and it looks like there's a replaced version of 'ubiattach' that requires a different parameter set.

maybe you can specify the full path to the original '/sbin/ubiattach' in your script, as that one works correct:

Code: Select all

# /sbin/ubiattach  -m 6 -d 2
UBI device number 2, total 120 LEBs (15237120 bytes, 14.5 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
# mount -vt ubifs ubi2:config /tmp/dom.tmp
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

Good work, will do. :geek:

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

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

sthones wrote: Mon May 06, 2019 4:44 am maybe you can specify the full path to the original '/sbin/ubiattach' in your script, as that one works correct:
This is now complete. Can you please try the latest script?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
sthones
New here
Posts: 8
Joined: Mon Oct 22, 2018 11:49 pm

Re: [SCRIPT] create-autorun.sh

Post by sthones »

OneCD wrote: Mon May 06, 2019 8:23 am
sthones wrote: Mon May 06, 2019 4:44 am maybe you can specify the full path to the original '/sbin/ubiattach' in your script, as that one works correct:
This is now complete. Can you please try the latest script?
initially this now ran into issues again, due to the manual commands I had executed before:

Code: Select all

create-autorun.sh (190506)

[ info ] NAS model: TS-X31P2 (TS-231P2)
[ info ] QTS version: 4.3.6 #20190328
[ info ] default volume: /share/CACHEDEV1_DATA

[ done ] DOM partition found (/dev/mtd6)
[ fail ] Unable to ubiattach! [ubiattach: error!: cannot attach mtd6
           error 17 (File exists)]
[ info ] will try as (ext4) instead
[ fail ] Unable to mount (ext4) DOM partition (/dev/mmcblk0p7)! Error: [mount: special device /dev/mmcblk0p7 does not exist]

[ fail ] [autorun.sh] creation failed!
but after I manually executed:

Code: Select all

# /sbin/ubidetach -m 6
it then succeeded. you might want to make this handling more tolerant, but now it's working fine for me!

thanks for your help!
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

sthones wrote: Mon May 06, 2019 1:56 pm it then succeeded. you might want to make this handling more tolerant, but now it's working fine for me!
The script is used to make a successful 'ubiattach', which is followed shortly after by a corresponding (and automated) 'ubidetach'.

Yours is a case of me forgetting to mention to 'ubidetach' afterward. But it's not a situation I anticipate the script causing, or needing to manage on its own.

Thanks for reporting and testing this. We've made it better. :geek:

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
cactoid
New here
Posts: 4
Joined: Sat Jun 01, 2019 3:11 am

Re: [SCRIPT] create-autorun.sh

Post by cactoid »

Thanks for this it's saved me quite some headache in setting things up - however I'm trying to run a node.js app as part of the startup but don't seem to be having much luck

I've made a simple script and added it to the scripts folder and set the executable permission, it's basically a one-liner e.g.:

Code: Select all

node /myDir/myApp/myapp.js &
Checking the logs the script is being found and run but the app itself doesn't actually execute, if I SSH into the QNAP (TS-431P off the top of my head) and manually run autostart.sh or my own script everything works fine.

Reading around I've seen some mention of node not being available on boot but I'm not too clear on how to get around that (delaying autostart perhaps?) or if there's some other way to do this - would you have any ideas or experience around this?

Any help would be greatly appreciated, thank you
User avatar
OneCD
Guru
Posts: 12143
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [SCRIPT] create-autorun.sh

Post by OneCD »

Hi and welcome to the forum. :)
cactoid wrote: Sat Jun 01, 2019 3:21 am Thanks for this it's saved me quite some headache in setting things up - however I'm trying to run a node.js app as part of the startup but don't seem to be having much luck
NodeJS isn't available when [autorun.sh] is executed. QPKGs are reintegrated into QTS after [autorun.sh]. ;)

For your use-case, suggest trying the RunLast QPKG instead.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Post Reply

Return to “Users' Corner”