Skip to content

Instantly share code, notes, and snippets.

@fire1ce
Last active September 26, 2024 13:55
Show Gist options
  • Save fire1ce/65d3e370120750a5deb283abe1d74491 to your computer and use it in GitHub Desktop.
Save fire1ce/65d3e370120750a5deb283abe1d74491 to your computer and use it in GitHub Desktop.
Install oh-my-zsh on openwrt/lede-project

Install oh-my-zsh on OpenWrt

Install Requirements Packages

opkg update && opkg install ca-certificates zsh curl git-http

Install oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Set zsh as default (thanks to @mlouielu)

which zsh && sed -i -- 's:/bin/ash:'`which zsh`':g' /etc/passwd

Prevent User Lockout

To prevent lock-outs after accidentially removing zsh(as explained in the wiki) you can add a check for zsh and fallback to ash in /etc/rc.local (thanks to @fox34):

# Revert root shell to ash if zsh is not available
if grep -q '^root:.*:/usr/bin/zsh$' /etc/passwd && [ ! -x /usr/bin/zsh ]; then
    # zsh is root shell, but zsh was not found or not executable: revert to default ash
    [ -x /usr/bin/logger ] && /usr/bin/logger -s "Reverting root shell to ash, as zsh was not found on the system"
    sed -i -- 's:/usr/bin/zsh:/bin/ash:g' /etc/passwd
fi
@VergilGao
Copy link

Cool, works also under OpenWrt 18.06.2
this worked for me:
->
opkg update && opkg install ca-certificates zsh curl git-http
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sed -i -- 's:/bin/ash:/usr/bin/zsh:g' /etc/passwd
logged out, and in again, and Oh-My-ZSH was working ------------------>Thanks

which zsh /usr/bin/zsh i edit /etc/passwd. change ash's path to zsh's path. i cannot ssh login anymore. "Permission denied, please try again." i can web login.

just add
/usr/bin/zsh
to /etc/shells

your /etc/shells would be like:

$ cat /etc/shells
/bin/ash
/bin/bash
/bin/rbash
/usr/bin/zsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment