initial commit

This commit is contained in:
ray 2020-02-17 20:21:31 +00:00
commit 6ef6f715d7
3 changed files with 55 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
`install.sh` -- install all files in `./src/` to install directory (`/usr/local/bin/`).
`install.sh -u` -- uninstall all files in `./src/` from install directory.

39
install.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
_install_dir="/usr/local/bin/"
_uninstall=0
for _arg in "$@" ; do
if [ "$_arg" = "-u" ] || [ "$_arg" = "--uninstall" ] ; then
_uninstall=1
else
echo "warning: unknown option."
exit 1
fi
done
echo "Install directory: '$_install_dir'"
echo ""
for _file in ./src/* ; do
if [ $_uninstall -eq 0 ] ; then
echo "installing: $_file"
sudo cp "$_file" "$_install_dir"
elif [ $_uninstall -eq 1 ] ; then
_filename=$(basename "$_file")
# WARNING - need to ensure $_filename is not empty (/usrlocal/bin will be deleted)
if [ -n "$_filename" ]; then
echo "uninstalling: $_filename"
sudo rm "$_install_dir$_filename"
fi
fi
done
if [ $_uninstall -eq 0 ] ; then
echo ""
echo "Install complete -- uninstall with"
echo " ./install -u"
else
echo ""
echo "Uninstall complete"
fi

14
src/newsh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -e
if [ -f "$1" ] ; then
echo "Error: file exists: $1"
exit 1
fi
echo "#!/bin/sh" > "$1"
echo "" >> "$1"
echo "$2" >> "$1"
chmod u+x "$1"