Giter Club home page Giter Club logo

create-autorun's Introduction

create-autorun icon

Description

This is a run-once BASH script to create an autorun environment on your QNAP NAS. This can be used to automatically execute your own scripts when the NAS boots-up.

The aim of this project is to support all QNAP NAS models and all QTS & QuTS hero versions. Please advise if you encounter any errors when running it on your NAS.

What it does

This installer script writes an autorun.sh processor into your default volume, below the .system directory. It then symlinks this from the DOM back to your default data volume so that it is run on NAS startup. This means you don't need to load the DOM partition every time you want to change the contents of autorun.sh

The autorun device and partition are automatically determined by this script.

How to create your autorun.sh

curl -skL https://git.io/create-autorun | sudo bash

Notes

  • If you didn't have an autorun.sh file before, then the autorun.sh file created by this utility will contain a script directory processor, and will make a scripts directory available for your own shell-scripts. Everything in this scripts directory is run (in-order) during NAS startup by the default autorun.sh file created only. The notes below are only applicable to the autorun.sh written by this utility. If you already had another autorun.sh file, then it will remain and be used instead, and the following notes won't apply.

  • The location of the autorun system will depend on your default volume name. For example: if your default volume is CACHEDEV1_DATA, then the automatic script processor will be created at:

/share/CACHEDEV1_DATA/.system/autorun/autorun.sh

... and the scripts directory will be created at:

/share/CACHEDEV1_DATA/.system/autorun/scripts/
  • autorun.sh is triggered at some point during NAS bootup, which then runs each executable file in the scripts directory in the default filename list order. If you need to run one script before the other, prefix them with a number such as:
10-example.sh
20-example.sh
25-example.sh
30-example.sh
  • A log file is created during autorun.sh execution. It is located at /var/log/autorun.log and contains the date-time and name of each of the executable scripts found in the scripts directory as they were run, along with any stdout and stderr generated by these scripts.

create-autorun's People

Contributors

aussielunix avatar hi-ko avatar onecdonly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-autorun's Issues

Installation error on QuTS Hero h5.0.1.2248

This is the output of
curl -skL https://git.io/create-autorun | sudo bash

create-autorun.sh (221208)

info: NAS model: TVS-h874 
info: QuTS version: 5.0.1 #20221215 
info: default volume: /share/ZFS1_DATA 
done: found autorun partition: /dev/sda6 
done: created mount-point: /tmp/create-autorun.wIvBKx 
done: mounted ext2 autorun partition /dev/sda6: /tmp/create-autorun.wIvBKx 
fail: Tag-file /tmp/create-autorun.wIvBKx/uLinux.conf not found! 
done: unmounted ext2 autorun partition 
done: removed mount-point: /tmp/create-autorun.wIvBKx 

There is no autorun directory created in the default volume .system folder. Any ideas?

Not working on TS-231P2

  • 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!

ubiattach error 22 on TS-932PX

When running the create-autorun script, the script fails to mount the config partition:

[~] # curl -skL https://git.io/create-autorun | sudo bash
create-autorun.sh 230207

info: NAS model: TS-932PX
info: QTS version: 5.0.1 #20230112
info: default volume: /share/CACHEDEV1_DATA
info: autorun partition should be: /dev/mtd6
skip: unable to ubiattach 'ubiattach: error!: cannot attach mtd6
           error 22 (Invalid argument)'
info: will try as ext4 instead
fail: Unable to mount ext4 autorun partition: /dev/mtd6 'mount: special device /dev/mmcblk0p7 does not exist'

Running the command cat /proc/mtd it would appear that mtd6 is the correct device for the config region:

[~] # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00150000 00001000 "loader"
mtd1: 00060000 00001000 "env"
mtd2: 02000000 00020000 "boot1_kernel"
mtd3: 0d800000 00020000 "boot1_rootfs2"
mtd4: 02000000 00020000 "boot2_kernel"
mtd5: 0d800000 00020000 "boot2_rootfs2"
mtd6: 00f00000 00020000 "config"

I tried to manually run ubiattach with a few different argument syntaxes to no avail:

[~] # sudo /sbin/ubidetach /dev/ubi_ctrl -m 6
ubidetach: error!: cannot detach mtd6
           error 19 (No such device)
[~] # sudo /sbin/ubiattach /dev/ubi_ctrl -m 6
ubiattach: error!: cannot attach mtd6
           error 22 (Invalid argument)
[~] # ubiattach -m 6 -d 2
ubiattach: error!: cannot attach mtd6
           error 22 (Invalid argument)
[~] # sudo /sbin/ubiattach -p /dev/mtd6
ubiattach: error!: cannot attach "/dev/mtd6"
           error 22 (Invalid argument)
[~] # sudo /sbin/ubiattach -p /dev/mtd6ro
ubiattach: error!: cannot attach "/dev/mtd6ro"
           error 22 (Invalid argument)

Out of desperation I tried running ubiattach on mtd5 and that was successful:

[~] # sudo /sbin/ubiattach -p /dev/mtd5
UBI device number 0, total 1728 LEBs (219414528 bytes, 209.2 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)

I'm not sure what the next step is to troubleshoot this. Any suggestions are appreciated.

Run script on shutdown

Hello
Any chance to add a section that run when device shutting down?
I saw a german guy uploaded an autorun.sh on the other froum but is it safe to replace the file with your file? I can provide the file in case you want me to do it

Permissions for user script files

Please add a reminder to README for the permissions needed on files

10-example.sh
20-example.sh

I forgot to +x, took me awhile to figure out. [mostly due to not wanting to reboot again] (not sure what user/group they should be as best practice, mine resulted with. -rwxr-xr-x 1 admin administrators) And works now

Thanks !!

Not working on TAS-268

End with the following output:

info: NAS model: TAS-268
info: QTS version: 4.3.3 #20220303
info: default volume: /share/CACHEDEV1_DATA
info: autorun partition should be: /dev/mtd6
skip: unable to ubiattach 'ubiattach: error!: UBI is not present in the system'
info: will try as ext4 instead
done: mounted ext4 autorun partition: /dev/mtd6 -> /tmp/create-autorun.GKSQvl
fail: Partition tag-file not found
done: unmounted ext4 autorun partition
ubidetach: error!: UBI is not present in the system

SSH unable to run

Sadly I can't get openssh to run, even though it is specified in a script in autorun/scripts.

QNAP TS-431P:

[~] # uname -a
Linux NAS31D3FC 4.2.8 #2 SMP Tue Nov 28 05:34:53 CST 2023 armv7l unknown

I have installed Entware_1.03a_std.qpkg from Entware, and installed openssh-server.

I run create-autorun:

[~] # curl -skL https://git.io/create-autorun | sudo bash
create-autorun.sh 230527

info: NAS model: TS-431P 
info: QTS version: 5.1.4 #20231128 
info: default volume: /share/CACHEDEV1_DATA 
info: autorun partition should be: /dev/mtd6 
done: ubiattached partition: 6 
done: mounted: ubifs device: ubi2:config -> /tmp/create-autorun.S1odE3 
info: confirmed partition tag-file exists: uLinux.conf (we're in the right place) 
skip: autorun.sh already exists: /share/CACHEDEV1_DATA/.system/autorun/autorun.sh 
skip: symlink from partition already exists and points to: /share/CACHEDEV1_DATA/.system/autorun/autorun.sh 
skip: autorun.sh is already enabled in OS 
done: unmounted ubifs autorun partition 
info: your autorun.sh file is located at: /share/CACHEDEV1_DATA/.system/autorun/autorun.sh 

Then add my openssh startup script:

[~] # cat /share/CACHEDEV1_DATA/.system/autorun/scripts/openssh.sh
# Start OpenSSH
echo "autorun/scripts/openssh.sh: Running"
/opt/etc/init.d/S40sshd start

Then reboot.

On boot, openssh is not running:

[~] # ps -a | grep ssh
14348 admin      2140 S   /usr/sbin/sshd -f /etc/config/ssh/sshd_config -p 13022 
19495 admin      6064 S   sshd: admin@pts/0                                         
25150 admin       444 S   grep ssh 

And the log says /opt/etc/init.d/S40sshd: No such file or directory.

[~] # cat /var/log/autorun.log
Thu Jan  4 05:41:48 GMT 2024 -- begin processing --
Thu Jan  4 05:41:48 GMT 2024 executing /share/CACHEDEV1_DATA/.system/autorun/scripts/openssh.sh ...
autorun/scripts/openssh.sh: Running
/share/CACHEDEV1_DATA/.system/autorun/scripts/openssh.sh: line 3: /opt/etc/init.d/S40sshd: No such file or directory
Thu Jan  4 05:41:48 GMT 2024 -- end processing --

Clearly the Autorun component is working, so I know perhaps it is not your program's issue.

But do you have any insight into how I can troubleshoot this?

I'm quite deep in forum posts from 2010-2023 and can't get anywhere.

Would appreciate any insight if you happen to have the time.

Autorun script not executed on startup

Installing the script works fine.

curl -sk https://raw.githubusercontent.com/onecdonly/create-autorun/master/create-autorun.sh | bash

  • script version : 181102
  • NAS model : TS-X28A (TS-212P3)
  • QTS version : 4.3.6 #20190308
  • default volume : /share/CACHEDEV1_DATA

√ DOM partition found : /dev/mmcblk0p5
√ mounted (ext2) DOM partition at : /tmp/create-autorun.T8mqmV
√ backed-up existing autorun.sh to : /share/CACHEDEV1_DATA/.system/autorun/autorun.sh.prev.6
√ unmounted (ext2) DOM partition : /tmp/create-autorun.T8mqmV

√ autorun.sh successfully created!

I created some autorun script in the scripts folder
/share/CACHEDEV1_DATA/.system/autorun/scripts

The scripts run fine (I executed them manually after boot).
But it is not run when the system reboot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.