How to run a boot script at MyCloud Gen2 (2.11.xx) devices
Disclaimer: The following can brick your device. Please use only if you are fit with crontabs and unix shell scripting.
The latest myclouds are rather closed systems. You can change some settings with the web dashboard, but everything else you do on a shell level will be gone after reboot.
User @Fox_exe has done some amazing work to set up a chroot debian environment parallel to the built in system. But after reboot you have to set it up again by hand from shell.
Running a user boot script is not available. Except if you use the following hack.
ssh into your mycloud. cd to /usr/local/config.
The file config.xml contains the settings you locally set up from the dash board.
You will find some cron entries in config.xml. We will „abuse“ one cron entry to run our boot script
Save your original crontab. Run „crontab -l > crontab.orig“
Edit config.xml. Find the entry for „stime“
Edit this entry to run your boot script.
<stime> <count>1</count> <item id="1"> <method>3</method> <1>*</1> <2>*</2> <3>*</3> <4>*</4> <5>*</5> <run>/usr/local/config/boot-script &</run> </item> </stime>
This will run your boot script immediatly after reboot when crond starts.
Your boot script must do the following steps:
- recover original crontab
- make sure script it is not run twice
- do whatever you want after boot
My boot script looks like that:
#! /bin/sh CRONTAB=/var/spool/cron/crontabs/root CONFIG=/usr/local/config BOOTRUN=/tmp/bootscript-run # Remove boot-script from crontab and # recover crontab cd $CONFIG cp crontab.orig $CRONTAB # don't run twice if [ -f $BOOTRUN ]; then exit 0 fi touch $BOOTRUN # boot code comes here # root profile cp profile.local $HOME/.profile # other user jobs
That’s it. Your boot script will be run rather early in the boot process (when crond starts up). You may need some delay (sleep) to wait until your mycloud is fully booted and running.
After a firmware upgrade, you may need to set it up again. So save your scripts!