Create a Custom Capsule (aka Custom Firmware) [with root]

Post Reply
pirre
Posts: 3
Joined: Thu Jan 03, 2013 6:59 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by pirre » Thu Jan 03, 2013 7:00 am

Hello everyone! Best wishes for 2013!

I read all these posts and the wiki with great interested. While creating the capsule I got errors.
Here is the log, can anyone see what went wrong?

thanks!

-------------------------------------------------
Custom Capsule Creator Script v7
-------------------------------------------------

Analysing your system:
- directory exists ..........no
Do you want to create '/Users/pbreugel/Downloads/lacie' directory? [y/n]: y
OK (done)
- lzma installed ..........yes (/usr/local/bin/lzma)
- wget installed ..........yes (/usr/local/bin/wget)
- sha1sum installed ..........yes (/usr/local/bin/sha1sum)
- tar installed ..........yes (/usr/bin/tar)
- curl installed ..........yes (/usr/bin/curl)
- LaCie hardware: ..........not found
- LaCie firmware version: ..........not found

Choose what to customize:
- Choose LaCie hardware you want to customize:
1. Network Space 2
2. Network Space MAX
3. d2 Network 2
4. 2big Network 2
5. 5big Network 2
Choose one option: 3
- Choose original capsule version to download and customize:
1. Version 1.1.3
2. Version 1.1.7
3. Version 2.0.4
4. Version 2.0.5
5. Version 2.1.2
6. Version 2.2.3
7. Version 2.2.4
8. Version 2.2.5
9. Version 2.2.8
10. Version 2.2.8.3
Choose one option: 10
- Do you want to have root access? [y/n]: y
- Do you want to access TwonkyMedia server web configuration and browse? [y/n]: y
- Do you want to access Transmission Web Interface? [y/n]: y
- Do you want to secure access from a external network? [y/n]: n

Preparing:
- Deleting old versions: ..........OK (done)

Downloading original capsule:
- Downloading d2 Network 2 2.2.8.3 capsule
--2013-01-03 07:52:09-- ftp://d2network2:*password*@d2network2- ... .3.capsule
=> ‘d2network2_2.2.8.3.capsule’
Resolving d2network2-update.lacie.com... 88.198.15.210
Connecting to d2network2-update.lacie.com|88.198.15.210|:21... connected.
Logging in as d2network2 ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /1.1/prod/2.2.8.3 ... done.
==> SIZE d2network2_2.2.8.3.capsule ... 73135943
==> PASV ... done. ==> RETR d2network2_2.2.8.3.capsule ... done.
Length: 73135943 (70M) (unauthoritative)

100%[=========================================================================>] 73,135,943 481KB/s in 2m 32s

2013-01-03 07:54:42 (469 KB/s) - ‘d2network2_2.2.8.3.capsule’ saved [73135943]

OK (done)

Extracting capsule:
- Extracting original (2.2.8.3) capsule ..........sed: RE error: illegal byte sequence
OK (done)
- Unpacking original (2.2.8.3) capsule tarball ..........OK (done)
- Unpacking original (2.2.8.3) rootfs tarball (can take up to 5 minutes) .........../usr/share/terminfo/p/p14-m-w: Can't create 'usr/share/terminfo/p/p14-m-w'
./usr/share/terminfo/p/p12-m-w: Can't create 'usr/share/terminfo/p/p12-m-w'
./usr/share/terminfo/p/p8: Can't create 'usr/share/terminfo/p/p8'
./usr/share/terminfo/p/p14-w: Can't create 'usr/share/terminfo/p/p14-w'
./usr/share/terminfo/p/p7: Can't create 'usr/share/terminfo/p/p7'
./usr/share/terminfo/p/p4: Can't create 'usr/share/terminfo/p/p4'
./usr/share/terminfo/p/prism14-w: Can't create 'usr/share/terminfo/p/prism14-w'
./usr/share/terminfo/p/p12: Can't create 'usr/share/terminfo/p/p12'
./usr/share/terminfo/p/prism4: Can't create 'usr/share/terminfo/p/prism4'
./usr/share/terminfo/p/prism12-m-w: Can't create 'usr/share/terminfo/p/prism12-m-w'
./usr/share/terminfo/p/p14-m: Can't create 'usr/share/terminfo/p/p14-m'
./usr/share/terminfo/p/p9-8: Can't create 'usr/share/terminfo/p/p9-8'
./usr/share/terminfo/p/p9: Can't create 'usr/share/terminfo/p/p9'
./usr/share/terminfo/p/prism9: Can't create 'usr/share/terminfo/p/prism9'
./usr/share/terminfo/p/prism8: Can't create 'usr/share/terminfo/p/prism8'
./usr/share/terminfo/p/p5: Can't create 'usr/share/terminfo/p/p5'
./usr/share/terminfo/p/p12-w: Can't create 'usr/share/terminfo/p/p12-w'
./usr/share/terminfo/p/prism14-m-w: Can't create 'usr/share/terminfo/p/prism14-m-w'
./usr/share/terminfo/p/p9-8-w: Can't create 'usr/share/terminfo/p/p9-8-w'
./usr/share/terminfo/p/prism5: Can't create 'usr/share/terminfo/p/prism5'
./usr/share/terminfo/p/prism12: Can't create 'usr/share/terminfo/p/prism12'
./usr/share/terminfo/p/p12-m: Can't create 'usr/share/terminfo/p/p12-m'
./usr/share/terminfo/p/p9-w: Can't create 'usr/share/terminfo/p/p9-w'
./usr/share/terminfo/p/p14: Can't create 'usr/share/terminfo/p/p14'
./usr/share/terminfo/p/prism14-m: Can't create 'usr/share/terminfo/p/prism14-m'
./usr/share/terminfo/p/p8-w: Can't create 'usr/share/terminfo/p/p8-w'
./usr/share/terminfo/p/prism9-w: Can't create 'usr/share/terminfo/p/prism9-w'
./usr/share/terminfo/2/2621a: Can't create 'usr/share/terminfo/2/2621a'
./usr/share/terminfo/h/hp70092a: Can't create 'usr/share/terminfo/h/hp70092a'
./usr/share/terminfo/h/hp2621A: Can't create 'usr/share/terminfo/h/hp2621A'
./usr/share/terminfo/h/hp2621-wl: Can't create 'usr/share/terminfo/h/hp2621-wl'
./usr/share/terminfo/h/hp2621a: Can't create 'usr/share/terminfo/h/hp2621a'
./usr/share/terminfo/h/hp2621: Can't create 'usr/share/terminfo/h/hp2621'
./usr/share/terminfo/h/hp70092: Can't create 'usr/share/terminfo/h/hp70092'
./usr/share/terminfo/n/ncr260vt300wpp: Can't create 'usr/share/terminfo/n/ncr260vt300wpp'
./usr/share/terminfo/n/ncrvt100wpp: Can't create 'usr/share/terminfo/n/ncrvt100wpp'
tar: Error exit delayed from previous errors.
OK (done)

Duplicating capsule:
- Duplicating to custom (2.2.8.3.1) capsule folder ..........cp: illegal option -- d
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
rm: capsule_d2network2_2.2.8.3.1/repository/rootfs.tar.lzma: No such file or directory
OK (done)
- Duplicating to custom (2.2.8.3.1) rootfs folder (can take up to 3 minutes) ..........cp: illegal option -- d
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
OK (done)

Customizing capsule:
- Enabling root access:
- Enabling sshd in default.runlevel ..........sed: -i may not be used with stdin
OK (done)
- Downloading custom 'sshd.i'
rootfs_d2network2_2.2.8.3.1/etc/initng/sshd.i: No such file or directory
Error downloading!

Mijzelf
Posts: 6205
Joined: Mon Jun 16, 2008 10:45 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by Mijzelf » Thu Jan 03, 2013 8:54 am

sed: RE error: illegal byte sequence
cp: illegal option -- d
sed: -i may not be used with stdin
It seems your basic tools sed and cp are not compatible. On what kind of system are you running the script?

pirre
Posts: 3
Joined: Thu Jan 03, 2013 6:59 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by pirre » Thu Jan 03, 2013 5:47 pm

Using the shell in Mac OS X 10.8.2 with Xcode, and all that stuff installed. Should be like Unix environment right?

pirre
Posts: 3
Joined: Thu Jan 03, 2013 6:59 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by pirre » Fri Jan 04, 2013 6:01 am

I was able to build properly:
-solved sed issue with setting LANG=C which is not automatically the case in shell under Mac OS X
-cp comment altered to cp -R -P -p and worked
no errors

But when I updated the d2 network 2 with 2.2.8.3 custom firmware, with any update method, the old firmware 2.2.8 is still there after reboot:
- with manual force update (Share/Update folder) nothing special happens
- with update via network assistant the NAS is blinking alternating red/blue a while during step 3 of 3, then unit reboots
Same result, old firmware remains on the NAS...

When I do force update via share/update folder with firmware update 2.2.8.3 from lacie website it works fine, although I also get blue/red alternate blinkin led and a beep. After that if I try updating to custom 2.2.8.3 from standard 2.2.8.3 the message is update successful but no root ssh, no twonky, ... happened only once after that via network assistant updates fail and force update just results in no firmware update... it does delete the custom capsule version from the share/update folder...
I also did factory reset and then tried updating, no luck either.

any suggestions?

metronomadic
Posts: 24
Joined: Thu Jun 10, 2010 8:40 pm

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by metronomadic » Fri Feb 08, 2013 6:37 pm

Just successfully rooted stock firmware v 2.2.5 on my Network Space 2 using the USB share / browser exploit shown here to create my custom firmware, then upgraded using the force update procedure. No root on the first boot, but rebooting gave me root access. Thank you!

Network Space 2
LacieOS | 2.2.5 (rooted) | 2.2.8.3 | Yes (on update, no root, restart it again and then root as enabled)

doritos
Posts: 6
Joined: Wed Feb 13, 2013 1:38 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by doritos » Fri Feb 15, 2013 6:52 pm

My 0.01 cents to this script

I've made some tweaks to Transmission, mainly to allow authentication on the web interface.

Since the authentication is also used in the internal RPC scripts, I had to update a few lines of code. It's not pretty, someone with better python skills can make this much better, but it works and allows you to use the LaCie web interface as well

It should be called inside /etc/initng/transmission.i

If your LaCie doesn't complete the boot process your your transmission does not start, restart the NAS to changes take affect.

Code: Select all

torrent_path=/shares/Midia/Downloads
incomplete_path=/shares/Midia/Downloads/.incomplete
username=desiredusername
password=desiredpassword

function do_replace {
	sed -i s\|"$1"\|"$2"\|g $3
}

if [ ! -e /lacie/torrent_dir/transmission/settings.json.backup ]; then
	cp -dp /lacie/torrent_dir/transmission/settings.json /lacie/torrent_dir/transmission/settings.json.backup
	cp -dp /usr/lib/python2.6/site-packages/unicorn/download/torrent.py \
		/usr/lib/python2.6/site-packages/unicorn/download/torrent.py.backup
fi


search=(
	"\"rpc-whitelist-enabled\": true," 
	"\"download-dir\": \"\/home\","
	"\"incomplete-dir\": \"\/root\/Downloads\","
	"\"rpc-authentication-required\": false,"
	"\"rpc-username\": \"\","
	"\"rpc-password\": \"\","
	"\"blocklist-enabled\": true,"
	)
replace=(
	"\"rpc-whitelist-enabled\": false," 
	"\"download-dir\": \"${torrent_path}\","
	"\"incomplete-dir\": \"${incomplete_path}\","
	"\"rpc-authentication-required\": true,"
	"\"rpc-username\": \"${username}\","
	"\"rpc-password\": \"${password}\","
	"\"blocklist-enabled\": false,"
	)

for ((i=0; i< ${#search[@]};i++)); do
	do_replace "${search[i]}" "${replace[i]}" /lacie/torrent_dir/transmission/settings.json
done

search=(
	"'rpc_whitelist_enabled', True"
	"'download_dir', u'\/home'"
	"'incomplete-dir', u'\/root\/Downloads'"
	"'rpc_authentication_required', False"
	"'rpc_username', u''"
	"'rpc_password', u''"
	"'blocklist_enabled', True"
	)
replace=(
	"'rpc_whitelist_enabled', False"
	"'download_dir', u'${torrent_path}'"
	"'incomplete_dir', u'${incomplete_path}'"
	"'rpc_authentication_required', True"
	"'rpc_username', u'${username}'"
	"'rpc_password', u'${password}'"
	"'blocklist_enabled', False"
	)

for ((i=0; i< ${#search[@]};i++)); do
	do_replace "${search[i]}" "${replace[i]}" /usr/lib/python2.6/site-packages/unicorn/download/torrent.py
done

sed -i "s/port=config.rpc_port,$/port=config.rpc_port, user=u'${username}', password=u'${password}',/g" \
	/usr/lib/python2.6/site-packages/unicorn/download/torrent.py


darodi
Posts: 1
Joined: Fri Mar 29, 2013 10:50 pm

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by darodi » Sat Mar 30, 2013 12:29 pm

I've been able to root my Network Space 2 using your script.
Thanks a lot!

Network Space 2

Custom capsulebuilt on | Original firmware version (rooted/not rooted) | Custom firmware version (rooted) | Got root access?
Ubuntu | networkspace2_1.2.92 not rooted | networkspace2_2.2.8.3.1 | yes (had to reboot 2 times)

djjeck
Posts: 2
Joined: Sun Apr 28, 2013 12:48 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by djjeck » Sun Apr 28, 2013 12:54 am

I just tried to upgrade my Lacie Network Space Max from 2.2.8.4, but the update isn't picked up.
In unicorn_core.log I found

Code: Select all

Apr 27 16:55:43 NAS [INFO update.check_for_capsule@70] capsule found: /media/internal_1/shares/1/Update/networkspacemax_2.2.8.4.1.capsule
Apr 27 16:55:43 NAS [DEBUG capsule.extract@254] extract files from /media/internal_1/shares/1/Update/networkspacemax_2.2.8.4.1.capsule
Apr 27 16:56:01 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/description.xml
Apr 27 16:56:01 NAS [DEBUG capsule.parse@186] parse XML
Apr 27 16:56:01 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/repository/bootfs.tar.lzma
Apr 27 16:56:01 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/uImage
Apr 27 16:56:02 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/exec/pre_exec/checkLogSize.sh
Apr 27 16:56:02 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/exec/pre_exec/updateBootfsLib.sh
Apr 27 16:56:02 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/exec/post_exec/cleanupLegacyFiles.sh
Apr 27 16:56:02 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/repository/uImage
Apr 27 16:56:02 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/exec/pre_exec/removeOldFiles.sh
Apr 27 16:56:02 NAS [DEBUG capsule.check@161] check SHA-1 hash of /capsule/repository/rootfs.tar.lzma
Apr 27 16:56:09 NAS [DEBUG capsule.check@170] original hash = 868003eafea172e252b5737a845b1bab40827c2d
Apr 27 16:56:09 NAS [DEBUG capsule.check@171] computed hash = 406b0d4c85e78c318cb8c3aab9a20775f90b5679
Apr 27 16:56:10 NAS [ERROR update.decapsule@101] an error occured when decapsuling
Apr 27 16:56:10 NAS Traceback (most recent call last):
Apr 27 16:56:10 NAS   File "/usr/lib/python2.6/site-packages/unicorn/system/update.py", line 97, in decapsule
Apr 27 16:56:10 NAS     capsule.extract()
Apr 27 16:56:10 NAS   File "/usr/lib/python2.6/site-packages/unicorn/system/capsule.py", line 261, in extract
Apr 27 16:56:10 NAS     self.__check_files()
Apr 27 16:56:10 NAS   File "/usr/lib/python2.6/site-packages/unicorn/system/capsule.py", line 332, in __check_files
Apr 27 16:56:10 NAS     CapsuleFile(os.path.join(self.directory, filename)).check(hash_val)
Apr 27 16:56:10 NAS   File "/usr/lib/python2.6/site-packages/unicorn/system/capsule.py", line 172, in check
Apr 27 16:56:10 NAS     raise CapsuleHashException('file %s has a bad hash' % self.filename)
Apr 27 16:56:10 NAS CapsuleHashException: file /capsule/repository/rootfs.tar.lzma has a bad hash
Apr 27 16:56:10 NAS [DEBUG module.stop_modules@397] Stopping unicorn.jobs
Apr 27 16:56:10 NAS [DEBUG module.stop_modules@397] Stopping unicorn.sharing.share
Apr 27 16:56:10 NAS [DEBUG share.shutdown@225] Shutting down shares...
Apr 27 16:56:11 NAS [DEBUG module.stop_modules@397] Stopping unicorn.network.bonjour
Apr 27 16:56:11 NAS [DEBUG module.stop_modules@397] Stopping unicorn.network.inadyn
Apr 27 16:56:11 NAS [DEBUG module.stop_modules@397] Stopping unicorn.system.email
Apr 27 16:56:11 NAS [DEBUG module.stop_modules@397] Stopping unicorn.storage.usb
Is this the error?
I created the capsule on a Mac, do you think it can be related?

liolio2
Posts: 1
Joined: Mon Apr 29, 2013 10:00 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by liolio2 » Mon Apr 29, 2013 10:07 am

I just successfully logged root building the 2.2.8.4.1 . Built the capsule on Ubuntu 12.10 and manually installed it using Mac OSX Network Assistant after a factory reset. Thank you...

djjeck
Posts: 2
Joined: Sun Apr 28, 2013 12:48 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by djjeck » Tue Apr 30, 2013 4:40 am

I built on Ubuntu and it worked. Guys, don't build on Mac.
Note that in the support screen, the version shown is still 2.2.8.4.
But I got root access. Thank you guys!

MechMK1
Posts: 12
Joined: Thu Jun 20, 2013 12:22 pm

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by MechMK1 » Tue Jun 25, 2013 10:44 am

To enforce running the script as root, add this at the very beginning:

Code: Select all

if [ $(id -u) != 0 ]
then
        echo "Must be root"
        exit 1
fi

ilpepe
Posts: 4
Joined: Sun Jul 28, 2013 3:22 pm

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by ilpepe » Sun Jul 28, 2013 3:30 pm

Hi,
I tried the script.
Script was generated, and the firmware, I think, succeeded.

The only problem is this:
PTY allocation request failed on channel 0
shell request failed on channel 0

when I ssh.

Twonky seems to work (able to connect to the webinterface)...

Any help?

best regards,
Pieter

Lacie Networkspace 2
firmware: 2.2.8.4 (modified)

ilpepe
Posts: 4
Joined: Sun Jul 28, 2013 3:22 pm

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by ilpepe » Sun Jul 28, 2013 11:04 pm

I started to doubt myself.
Up to now i did

Code: Select all

ssh admin@nas.ip
and i got this:

Code: Select all

PTY allocation request failed on channel 0
shell request failed on channel 0
I changed at did

Code: Select all

ssh -T admin@nas.ip
and got

Code: Select all

shell request failed on channel 0
And i just started wondering if i don't have to use root@nas.ip?
but no pw seems to work...

Any help?

Mijzelf
Posts: 6205
Joined: Mon Jun 16, 2008 10:45 am

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by Mijzelf » Mon Jul 29, 2013 7:55 pm

For the newer firmwares you'll have to use port 2222. On port 22 FTPS is running.

ilpepe
Posts: 4
Joined: Sun Jul 28, 2013 3:22 pm

Re: Create a Custom Capsule (aka Custom Firmware) [with root

Post by ilpepe » Tue Aug 06, 2013 12:17 am

Mijzelf wrote:For the newer firmwares you'll have to use port 2222. On port 22 FTPS is running.
Works perfectly!

I now have a total noob question. But I need some direction.

I rooted the NAS, and can do my stuff with it.
The thing is that before my ubuntu desktop automatically could mount the NAS, whilst this is nog impossible.
Probably something to do with permissions/file permissions, but I don't know where to start...

Any tips hints in the right direction. Just get me on the track, I'll google around, but right now I'm clueless...

Post Reply