bunkdeck/install.sh

123 lines
2.6 KiB
Bash
Raw Normal View History

2024-04-13 18:48:32 +00:00
#!/bin/sh -e
2024-04-13 23:35:41 +00:00
2024-05-13 22:16:06 +00:00
installtarget=/usr/local/bin
bunkchatrepo=https://git.bunk.computer/bunk/bunkchat.git
2024-04-13 18:48:32 +00:00
2024-05-13 22:16:06 +00:00
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
}
2024-04-22 20:15:21 +00:00
2024-05-13 22:16:06 +00:00
# check for tmux and cowsay
2024-04-22 20:15:21 +00:00
# if not prompt and exit
2024-05-13 22:16:06 +00:00
checkdeps() {
which tmux 1>/dev/null || missingtmux
which git 1>/dev/null || git
echo
echo 'deps located'
}
clonebunkchat() {
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
}
2024-04-22 20:15:21 +00:00
# install buckdeck in /usr/local/bin
2024-05-13 22:16:06 +00:00
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
2024-04-22 20:15:21 +00:00
2024-05-13 22:16:06 +00:00
checkdeps
checkbunkchat
installbunkdeck
infocron
exit 0