Objective
I wanted to use the
bash-shell
on my Synology DS209+II. There are no official packages from Synology provided, but I knew there is a way to install custom and optional packages via ipkg
.Motivation
As my Synology is mostly running 24/7, I wanted establish a custom download-script which is started and stopped as a cron-job at certain periods of time. The script itself uses some commands relying on a
bash-shell
, but the Synology default command shell is just the less powerful ash-shell
.
Prerequisites
- DS209+II
- ipkg - Custom package installer
Solution
Open a ssh-connection to your Synology
Log into your Synology as root using ssh (e.g "
ssh -l root DiskStation
").Install the
Bash-Shell-Package
:DiskStation$> ipkg install -A bash
You should see something like this:
DiskStation> ipkg install bash
Installing bash (3.2.54-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/bash_3.2.54-1_powerpc.ipk
Installing readline (6.1-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/readline_6.1-2_powerpc.ipk
Installing ncurses (5.7-3) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ncurses_5.7-3_powerpc.ipk
Configuring bash
Configuring ncurses
update-alternatives: Linking //opt/bin/clear to /opt/bin/ncurses-clear
Configuring readline
Successfully terminated.
Installing bash (3.2.54-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/bash_3.2.54-1_powerpc.ipk
Installing readline (6.1-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/readline_6.1-2_powerpc.ipk
Installing ncurses (5.7-3) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ncurses_5.7-3_powerpc.ipk
Configuring bash
Configuring ncurses
update-alternatives: Linking //opt/bin/clear to /opt/bin/ncurses-clear
Configuring readline
Successfully terminated.
Now,
Bash-Shell
is installed, but when you log into your Synology it's not yet automatically started. You are still with Ash-Shell
.Activate automatic log-in with Bash
You could exchange the shell type for log-in in your
/etc/passwd
on your Synology, by exchanging the line (here it's done for user: root):root:x:0:0:root:/root:/bin/ash
by
root:x:0:0:root:/root:/bin/bash
Unfortunatelly doing so, has the disadvantage, that you might loose the ability to log into your Synology at all from remote after an upgrade of your Firmware. Because optional packages like
Bash
are installed into /opt
may be inavailable after a system-update. To prevent this accidental lock-out, it's preferred to continue to log-in with Ash-Shell
, but start Bash
automatically at once after you're successfully logged in.To achive this you have to create/edit the file
.profile
in the homeaccount of the user the should be able to log-in on your Synology. Go to your homeaccount (e.g. /root/
for the user: root) and type the following as the proper user on you Synology:DiskStation$> vi .profile
If the file has content, just add this lines to it:
# ...
if [[ -x /opt/bin/bash ]]; then
exec /opt/bin/bash
fi
if [[ -x /opt/bin/bash ]]; then
exec /opt/bin/bash
fi
That's it. Next time, when
root
logs into your Synology, he is on a Bash-Shell
.Refine Configuration
If you want to use a different command prompt or to have some alias-commands, or at least the proper shell name in your "SHELL" environment variable, it's advisable also to create a
.bashrc
in the homeaccount, with the following example content (feel free to alter it to your convenience): DiskStation$> vi .bashrc
PS1='\u@\h:\w \$ '
export SHELL=/opt/bin/bash
export SHELL=/opt/bin/bash
The first line gives you a nice bash prompt. The second explicitly sets the "SHELL" variable to your correct shell.
If you want also other scripts automatically using
Bash
instead of Ash
, additionally create a symbolic link to it in /bin/
:DiskStation$> ln -s /opt/bin/bash /bin/bash
ADVICE: Keep a separate root shell window open until you have confirmed all of the changes work.