Using Oh My Zsh in unRAID?


8 posts in this topic Last Reply

Recommended Posts

Hey!, 

 

So, I wanna use zsh+Oh My Zsh in the unRAID shell but I'm having some issues with the setup so that it gets re-installed on every reboot. I enabled zsh using the nerd pack plugin then I can install OMZ manually and it works perfectly but I can't figure out how to make it persist after a reboot. 

 

In summary. I enabled zsh on the nerd pack and added these lines to my go script: 
 

Quote

# Install Oh My ZSH!
chsh -s $(which zsh)
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
cp /boot/extra/scripts/oh-my-zsh/.zshrc /root/

 

The result is that I get zsh as the default shell correctly but the weird thing is that when I SSH into unRAID using PuTTy I don't have Oh My Zsh installed and yet in the command prompt in the actual server (as in, the video output from that computer) I see it installed correctly. 

 

Am I missing anything?. 

Link to post
  • 1 year later...

Yes, running from the go file or from user scripts, you will have issues (just like I did). The install script uses home variables, which do not expand properly (instead of ~/ becoming /root, it becomes //).

 

I broke down the installer script, and fixed it for unraid. Here is what I use:

ZSH="/root/.oh-my-zsh"
umask g-w,o-w
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH
cp "$ZSH"/templates/zshrc.zsh-template /root/.zshrc
sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\"
" /root/.zshrc > /root/.zshrc-omztemp
mv -f /root/.zshrc-omztemp /root/.zshrc
chsh -s $(which zsh)
env zsh -l

 

Link to post
  • 2 weeks later...
  • 1 month later...
On 1/1/2019 at 10:25 PM, d2dyno said:

I figured out a simpler way, just define $HOME for scripts:


HOME="/root"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

 

Thought I'd just mention......zsh is in the unraid NerdPack plugin......that is probably the easiest way to install zsh and have it persist through reboots. If you haven't used NerdPack plugin, I'd suggest looking into it. Makes installing various tools and have them persist extremely easy

Edit: Apologies.....you referring to Oh-My-Zsh.....

Edited by Stupifier
Link to post
  • 1 year later...
7 minutes ago, xthursdayx said:

Late post, but hopefully one of you all might see this. I was just wondering how you're handling making your .zshrc and any plugins persistent? Thanks!

I used the User Scripts plugin to run this script on first start of array :

#!/bin/bash

# umask setup
umask 077

# Variable Setup
CONFIG=/boot/config/ssh
HOME_SSH=/root/.ssh
ZSH="/root/.oh-my-zsh"

mkdir -p $HOME_SSH
cp $CONFIG/pre-set/* $HOME_SSH
chmod 700 $HOME_SSH
chmod 644 $HOME_SSH/id_rsa.pub
chmod 600 $HOME_SSH/id_rsa
chmod 600 $HOME_SSH/authorized_keys

### Install zsh shits
HOME="/root"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
umask g-w,o-w
chsh -s $(which zsh)
env zsh -l

newplugins="git tmux zsh-autosuggestions"

sed -i  "s/(git)/($newplugins)/" /root/.zshrc
sed -i "s#\(ZSH_THEME *= *\).*#\1agnoster#" /root/.zshrc
echo "cd /mnt/user/" >> /root/.zshrc
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH/custom/plugins/zsh-autosuggestions
chmod 700 /root/.oh-my-zsh/custom/plugins/zsh-autosuggestions
###

# Copy terminal (zsh) history
cp /boot/config/.zsh_history /root

Combined with this array stop script to copy ZSH history and SSH keys:

#!/bin/bash

# Copy terminal (zsh) history
touch /boot/config/.zsh_history
echo "$(cat /root/.zsh_history)" >> /boot/config/.zsh_history

# Variable Setup
CONFIG=/boot/config/ssh
HOME_SSH=/root/.ssh
# Copy any new keys on exit
rsync -avhW $HOME_SSH/ $CONFIG/pre-set

As for .zshrc (or aliases), I use /boot/config/go to write to /etc/profile on startup (how I was taught here to do it):

# Re-make aliases on boot
echo "
#### Aliases copied from /boot/config/go ####
alias size='du -c -h -d 1 | sort -h'
export TERM=xterm-color
#### End Aliases ####">>/etc/profile

These are just example aliases and settings, use your own (though I do love that size alias)

Edited by d2dyno
Link to post

Thanks @d2dyno !

 

Just to clarify, was there a reason you added these lines to /boot/config/go rather than your .zshrc?

On 12/7/2020 at 5:23 PM, d2dyno said:


# Re-make aliases on boot
echo "
#### Aliases copied from /boot/config/go ####
alias size='du -c -h -d 1 | sort -h'
export TERM=xterm-color
#### End Aliases ####">>/etc/profile

 

Edited by xthursdayx
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.