diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..efc960f --- /dev/null +++ b/install.sh @@ -0,0 +1,95 @@ +#!usr//bin/env bash +:<<'info' +shellnotes - install.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info + +dir="$(pwd)" +VER_TO_INSTALL=3.0 #This is used when updating, it will be changed in every new update +if [ -e ~/.shellnotes/.shellnotes.sh ]; then + echo "Shellnotes is already installed." + echo "If you want to update, please run 'update.sh'." + cd ~/.shellnotes/util/failed + g++ ifailed.cpp -o ifailed + ~/.shellnotes/util/failed/ifailed + rm -f ifailed + cd $dir +else + mkdir ~/.shellnotes + mv docs ~/.shellnotes/ + mv util ~/.shellnotes/ + mv def ~/.shellnotes/ + mv logs ~/.shellnotes/ + mv ver ~/.shellnotes/ + mv image ~/.shellnotes/ + mv shellnotes.sh ~/.shellnotes/.shellnotes.sh + mv $0 ~/.shellnotes/ + mv set_defaults.sh ~/.shellnotes/ + mv bash_update.sh ~/.shellnotes/ + mv uninstall.sh ~/.shellnotes/ + mv update.sh ~/.shellnotes/ + sudo mkdir /usr/local/man/man1 2>/dev/null + sudo cp ~/.shellnotes/docs/manpages/* /usr/local/man/man1/ + sudo gzip -f /usr/local/man/man1/*.1 + sudo mandb >/dev/null + sudo apt install g++ >/dev/null + sudo apt install python3 + sudo apt install python3-pip + pip install pathlib + sudo apt update + chmod +x ~/.shellnotes.sh + echo "$VER_TO_INSTALL" > ~/.shellnotes/ver/.shellnotes_version + if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then + echo "source ~/.shellnotes/.shellnotes.sh" >> ~/.zshrc + sed -i '1 i\#!/bin/zsh' ~/.shellnotes/.shellnotes.sh + clear + echo "Shellnotes was successfully istalled" + echo "------------------------------------" + echo "Please do 'source ~/.zshrc' and reopen your terminal to start using shellnotes." + echo "have fun taking notes!" + elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then + echo "source ~/.shellnotes/.shellnotes.sh" >> ~/.bashrc + sed -i '1 i\#!/bin/bash' ~/.shellnotes/.shellnotes.sh + clear + echo "Shellnotes was successfully istalled" + echo "------------------------------------" + echo "Please do 'source ~/.bashrc' and reopen your terminal to start using shellnotes." + echo "have fun taking notes!" + elif [ -n "`$SHELL -c 'echo $CSH_VERSION'`" ]; then + echo "source ~/.shellnotes/.shellnotes.sh" >> ~/.cshrc + sed -i '1 i\#!/bin/csh' ~/.shellnotes/.shellnotes.sh + clear + echo "Shellnotes was successfully istalled" + echo "------------------------------------" + echo "Please do 'source ~/.cshrc' and reopen your terminal to start using shellnotes." + echo "have fun taking notes!" + elif [ -n "`$SHELL -c 'echo $KSH_VERSION'`" ]; then + echo "source ~/.shellnotes/.shellnotes.sh~/.shellnotes.sh" >> ~/.kshrc + sed -i '1 i\#!/bin/ksh' ~/.shellnotes/.shellnotes.sh + clear + echo "Shellnotes was successfully istalled" + echo "------------------------------------" + echo "Please do 'source ~/.kshrc' and reopen your terminal to start using shellnotes." + echo "have fun taking notes!" + elif [ -n "`$SHELL -c 'echo $FISH_VERSION'`" ]; then + echo "source ~/.shellnotes/.shellnotes.sh" >> ~/.fishrc + sed -i '1 i\#!/bin/fish' ~/.shellnotes/.shellnotes.sh + clear + echo "Shellnotes was successfully istalled" + echo "------------------------------------" + echo "Please do 'source ~/.fishrc' and reopen your terminal to start using shellnotes." + echo "have fun taking notes!" + else + clear + echo "Your shell is not supported by shellnotes." + echo "Installation Failed." + cd ~/.shellnotes/util/failed + g++ ifailed.cpp -o ifailed + ~/.shellnotes/util/failed/ifailed + rm -f ifailed + cd $dir + fi +fi +cd $dir \ No newline at end of file diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..c874466 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,120 @@ +#!usr//bin/env bash +:<<'info' +shellnotes - uninstall.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info +clear +echo "Choose an option" +echo "----------------" +echo "1.Uninstall shellnotes and delete all files." +echo "2.Disable shellnotes and all its commands, but keep the files in your system." +echo "3.Enable shellnotes." +echo "" +echo -n "[1,2,3]: " && read option +if [ $option = "1" ]; then + if [ -e ~/.shellnotes/.shellnotes.sh ]; then + echo -n "Are you sure you want to delete Shellnotes?[Y/N]: " && read delete + case $delete in y|Y|YES|Yes|yes ) + cd ~/.shellnotes/ + rm -rfv ~/.shellnotes/.* 2>/dev/null + rm -f ~/.shellnotes/* 2>/dev/null + rm -rf ~/.shellnotes/docs 2>/dev/null + rm -rf ~/.shellnotes/util 2>/dev/null + rm -rf ~/.shellnotes/ver 2>/dev/null + rm -rf ~/.shellnotes/logs 2>/dev/null + rm -rf ~/.shellnotes/def 2>/dev/null + rm -rf ~/.shellnotes/image 2>/dev/null + cd .. + rmdir .shellnotes + if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then + if grep -q 'source ~/.shellnotes/.shellnotes.sh' ~/.zshrc; then + sed -i '/shellnotes/d' .zshrc + clear + echo "Shellnotes is uninstalled" + echo "--------------------------" + echo "It was fun taking notes with you!" + fi + elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then + if grep -q 'source ~/.shellnotes/.shellnotes.sh' ~/.bashrc; then + sed -i '/shellnotes/d' ~/.bashrc + clear + echo "Shellnotes is uninstalled" + echo "--------------------------" + echo "It was fun taking notes with you!" + fi + elif [ -n "`$SHELL -c 'echo $CSH_VERSION'`" ]; then + if grep -q 'source ~/.shellnotes/.shellnotes.sh' ~/.cshrc; then + sed -i '/shellnotes/d' ~/.cshrc + clear + echo "Shellnotes is uninstalled" + echo "--------------------------" + echo "It was fun taking notes with you!" + fi + elif [ -n "`$SHELL -c 'echo $KSH_VERSION'`" ]; then + if grep -q 'source ~/.shellnotes/.shellnotes.sh' ~/.kshrc; then + sed -i '/shellnotes/d' ~/.kshrc + clear + echo "Shellnotes is uninstalled" + echo "--------------------------" + echo "It was fun taking notes with you!" + fi + elif [ -n "`$SHELL -c 'echo $FISH_VERSION'`" ]; then + if grep -q 'source ~/.shellnotes/.shellnotes.sh' ~/.fishrc; then + sed -i '/shellnotes/d' ~/.fishrc + clear + echo "Shellnotes is uninstalled" + echo "--------------------------" + echo "It was fun taking notes with you!" + fi + else + echo "Your shell is not supported." + cd ~/.shellnotes/util/failed + g++ uninfailed.cpp -o uninfailed + ~/.shellnotes/util/failed/uninfailed + rm -f uninfailed + cd $dir + fi + esac + else + echo "An error occured." + echo "Shellnotes is not installed." + cd ~/.shellnotes/util/failed + g++ uninfailed.cpp -o uninfailed + ~/.shellnotes/util/failed/uninfailed + rm -f uninfailed + cd $dir + fi + + +elif [ $option = "2" ]; then + if grep 'return' <~/.shellnotes/.shellnotes.sh >/dev/null; then + echo "Shellnotes is already disabled." + cd ~/.shellnotes/util/failed + g++ disfailed.cpp -o disfailed + ~/.shellnotes/util/failed/disfailed + rm -f disfailed + cd $dir + else + sed -i '2 i\return 0 #Shellnotes is disabled by the user. Do not change this line.' ~/.shellnotes/.shellnotes.sh + echo "Shellnotes is now disabled. To enable, run this script again and choose option (3)." + fi +elif [ $option = "3" ]; then + if grep 'return' <~/.shellnotes/.shellnotes.sh >/dev/null; then + sed -i '2d' ~/.shellnotes/.shellnotes.sh + echo "Shellnotes is now enabled. Please restart your terminal." + else + echo "Shellnotes is already enabled." + cd ~/.shellnotes/util/failed + g++ enfailed.cpp -o enfailed + ~/.shellnotes/util/failed/enfailed + rm -f enfailed + cd $dir + fi +else + echo "This is not an option." +fi + + + \ No newline at end of file