Separate platform-specific installers
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#! /bin/bash
|
||||
|
||||
zomp_dir="$HOME"/zomp
|
||||
bin="$HOME"/bin
|
||||
|
||||
cd "$(dirname $(realpath $0))"
|
||||
chmod +x uninstall
|
||||
|
||||
if [ -d "$zomp_dir" ]
|
||||
then
|
||||
echo "Installation directory $zomp_dir already exists. Aborting."
|
||||
exit 17
|
||||
fi
|
||||
|
||||
if [ ! -d "$bin" ]
|
||||
then
|
||||
echo "$bin does not exist. Creating it."
|
||||
mkdir "$bin"
|
||||
fi
|
||||
|
||||
if [[ ":$PATH:" == *":$bin:"* ]]
|
||||
then
|
||||
echo "$bin was found in \$PATH. Good to go."
|
||||
else
|
||||
echo "$bin was not found in \$PATH. Adding it."
|
||||
export PATH="$bin:$PATH"
|
||||
fi
|
||||
|
||||
for rc in "$HOME/.profile" "$HOME/.bashrc" "$HOME/.bash_profile"
|
||||
do
|
||||
if grep -q "PATH=\"\$HOME/bin:\$PATH\"" "$rc"
|
||||
then
|
||||
echo "Path adjustment found in $rc."
|
||||
else
|
||||
echo "Path adjustment not found in $rc. Adding it."
|
||||
echo "export PATH=\"\$HOME/bin:\$PATH\"" >> "$rc"
|
||||
fi
|
||||
done
|
||||
|
||||
cp -r zomp "$zomp_dir"
|
||||
cp unix/zx "$zomp_dir"
|
||||
cp unix/zxh "$zomp_dir"
|
||||
cp README.md "$zomp_dir"
|
||||
cp LICENSE "$zomp_dir"
|
||||
cp uninstall "$zomp_dir"
|
||||
ln -s "$zomp_dir"/zx "$bin"/zx
|
||||
ln -s "$zomp_dir"/zxh "$bin"/zxh
|
||||
|
||||
if zx_link=$(command -v zx)
|
||||
then
|
||||
echo "zx found at $zx_link. Checking for upgrade."
|
||||
echo "Running \`zx upgrade\`..."
|
||||
zx upgrade
|
||||
else
|
||||
echo "zx is not yet in \$PATH."
|
||||
echo "Add zx's location ($HOME/bin) to \$PATH run \`zx upgrade\`."
|
||||
fi
|
||||
Reference in New Issue
Block a user