122 lines
2.6 KiB
Bash
Executable file
122 lines
2.6 KiB
Bash
Executable file
#!/bin/sh -e
|
|
|
|
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
|
|
# if not prompt and exit
|
|
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
|
|
}
|
|
|
|
# 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
|