51 lines
1.2 KiB
Bash
Executable file
51 lines
1.2 KiB
Bash
Executable file
#!/bin/sh -e
|
|
|
|
installtarget=/usr/local/bin
|
|
chatlogdir=/var/log/bunkchat
|
|
chatlog=chat.log
|
|
|
|
chattrfailed() {
|
|
set +e
|
|
rm -rf $chatlogdir
|
|
echo
|
|
echo "ERROR: could not set append only attribute on ${chatlogdir}/${chatlog}"
|
|
echo " does your file system support 'chattr +a' ?"
|
|
exit 1
|
|
}
|
|
|
|
prep() {
|
|
mkdir -p $chatlogdir
|
|
chmod 755 $chatlogdir
|
|
touch ${chatlogdir}/${chatlog}
|
|
chmod 666 ${chatlogdir}/${chatlog}
|
|
# if chattr +a not supported on this file system, catch error and clean up
|
|
chattr +a ${chatlogdir}/${chatlog} || chattrfailed
|
|
}
|
|
|
|
install() {
|
|
cp proclaim heed scry $installtarget
|
|
chmod 755 ${installtarget}/proclaim
|
|
chmod 755 ${installtarget}/heed
|
|
chmod 755 ${installtarget}/scry
|
|
chown root:root ${installtarget}/proclaim
|
|
chown root:root ${installtarget}/heed
|
|
chown root:root ${installtarget}/scry
|
|
echo
|
|
echo "SUCCESS! bunkchat installed!"
|
|
exit 0
|
|
}
|
|
|
|
# check for root perms
|
|
if ! [ "$(id -u)" = 0 ]; then
|
|
echo
|
|
echo "ERROR: please run install with root permissions"
|
|
exit 1
|
|
fi
|
|
|
|
# if chat.log exists, skip prep
|
|
if [ -f ${chatlogdir}/${chatlog} ]; then
|
|
install
|
|
else
|
|
prep
|
|
install
|
|
fi
|