tmp install script

This commit is contained in:
sorrel 2024-05-13 18:16:06 -04:00
parent 434cb22405
commit 6a641c7e5c
2 changed files with 156 additions and 7 deletions

View file

@ -1,13 +1,122 @@
#!/bin/sh -e #!/bin/sh -e
# TODO installtarget=/usr/local/bin
bunkchatrepo=https://git.bunk.computer/bunk/bunkchat.git
missingtmux() {
echo
echo 'ERROR: tmux not found in $PATH'
echo ' please install tmux or add it to $PATH'
exit 1
}
missinggit() {
echo
echo 'ERROR: git not found in $PATH'
echo ' please install git or add it to $PATH'
exit 1
}
# check for tmux and cowsay # check for tmux and cowsay
# if not prompt and exit # if not prompt and exit
# pull in bunkchat checkdeps() {
# run bunkchat install script which tmux 1>/dev/null || missingtmux
# install buckdeck in /usr/local/bin which git 1>/dev/null || git
echo
echo 'deps located'
}
# prompt user to install delete.sh in /root/crontab-scripts/delete-bunkchat.sh clonebunkchat() {
# prompt with crontab config echo "cloning bunkchat repo"
git clone $bunkchatrepo
}
# if not found prompt for git clone or exit
prompttoclone() {
echo
echo "INFO: could not locate bunkchat scripts"
echo
printf "install bunkchat? (Y/n): "
read -r response
case $response in
n)
echo "exiting bunkchat install"
exit 0
;;
y)
clonebunkchat
;;
"")
clonebunkchat
;;
*)
prompttoclone
;;
esac
}
installbunkchat() {
(cd ../bunkchat && ./install.sh)
}
missingbunkchat() {
echo "bunk chat not installed"
# check for bunkchat repo in parent dir
needclone=1
for f in ./*
do
case $f in
bunkchat)
needclone=0
break
;;
esac
done
if [ $needclone == 1 ] ; then
prompttoclone
fi
# run bunkchat install script
installbunkchat
}
# check for installed bunkchat && continue
checkbunkchat() {
which heed 1>/dev/null || missingbunkchat
which proclaim 1>/dev/null || missingbunkchat
which scry 1>/dev/null || missingbunkchat
}
# install buckdeck in /usr/local/bin
installbunkdeck() {
echo "installing bunkchat"
cp bunkdeck $installtarget
chmod 755 ${installtarget}/bunkdeck
chown root:root ${installtarget}/bunkdeck
echo
echo "SUCCESS! bunkdeck installed!"
}
infocron() {
echo
echo "INFO: bunkdeck comes with a script to clear chat history"
echo " if you would like to enable this copy the script to crontab scripts"
echo " and enable a cron for your desired cadence"
echo
echo "# cp delete.sh /root/crontab-scripts/delete-bunkchat.sh"
echo "# crontab -u root -e"
echo "# EXAMPLE FOR WEEKLY HISTORY DELETION"
echo "0 0 * * 6 /root/crontab-scripts/delete-bunkchat.sh"
}
# check for root perms
if ! [ "$(id -u)" = 0 ]; then
echo
echo "ERROR: please run install with root permissions"
exit 1
fi
checkdeps
checkbunkchat
installbunkdeck
infocron
exit 0

40
uninstall.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/sh -e
installtarget=/usr/local/bin
# check for root perms
if ! [ "$(id -u)" = 0 ]; then
echo
echo "ERROR: please run install with root permissions"
exit 1
fi
echo
echo "uninstalling bunkdeck"
echo
printf "also uninstall bunkchat commands? (y/N): "
read -r response
case $response in
n)
rm ${installtarget}/bunkdeck
;;
"")
rm ${installtarget}/bunkdeck
;;
y)
(../bunkchat/uninstall.sh)
# 2>/dev/null || \
# echo && echo "ERROR: couldn't run bunkchat uninstall script" && exit 1
rm ${installtarget}/bunkdeck
;;
*)
echo
echo "ERROR: invalid response"
exit 1
;;
esac
echo
echo "SUCCESS: bunkdeck uninstalled"
echo " remember to clean up crontab /root/crontab-scripts/delete-bunkchat.sh"
exit 0