nagygergo/jetbrains-toolbox-install

Script fails if user doesn't have a /opt directory

Closed this issue · 3 comments

The current version of the script fails if the user has no /opt directory:

curl -fsSL https://raw.githubusercontent.com/nagygergo/jetbrains-toolbox-install/master/jetbrains-toolbox.sh | bash

...

Installing to /opt/jetbrains-toolbox

mkdir: cannot create directory ‘/opt/jetbrains-toolbox’: No such file or directory
chmod: cannot access '/opt/jetbrains-toolbox': No such file or directory
ln: failed to create symbolic link '/usr/local/bin/jetbrains-toolbox': File exists
chmod: cannot operate on dangling symlink '/usr/local/bin/jetbrains-toolbox'

I discovered this happens because this script is basically the first thing i run in a fresh distro install.

Hi,
I don't think that this script should /opt or any other system directory should be set up by this script, because permission control for those directories can have wide-ranging impacts. Setting up that directory should be an additional one-liner, and should be set up with the distro setup, instead of this userland script.

I understand. I didn't really think about all the implications. It's a very rare bug, though...

Is it possible to make a alert if the user doesn't have the /opt directory?

The unzipped file itself has execution permission, which can be executed directly

# unzip & install
tar -zxvf jetbrains-toolbox-1.25.12569.tar.gz
cd jetbrains-toolbox-1.25.12569 && ./jetbrains-toolbox

image

DIR="/opt/jetbrains-toolbox"
echo ""
echo  -e "\e[94mInstalling to $DIR\e[39m"
echo ""

if mkdir ${DIR}; then
    tar -xzf ${DEST} -C ${DIR} --strip-components=1
fi

chmod -R +rwx ${DIR}

ln -s ${DIR}/jetbrains-toolbox /usr/local/bin/jetbrains-toolbox
chmod -R +rwx /usr/local/bin/jetbrains-toolbox
echo ""
rm ${DEST}
echo  -e "\e[32mDone.\e[39m"

change: To meet your needs

DIR="/tmp/jetbrains-toolbox"
echo ""
echo  -e "\e[94mInstalling to $DIR\e[39m"
echo ""

#      if mkdir ${DIR}; then
#        tar -xzf ${DEST} -C ${DIR} --strip-components=1 # 解压到指定路径
#      fi

mkdir -p ${DIR}

tar -xzf ${DEST} -C ${DIR} --strip-components=1 # 解压到指定路径
chmod -R +rwx ${DIR}

bash ${DIR}/jetbrains-toolbox*
echo ""
rm ${DEST}
echo  -e "\e[32mDone.\e[39m"