a2cloud/setup/a2chat.txt
T. Joseph Carter c2deff81ae Re-indent the scripts a bit to match expectations
Notably this may cause issues diffing adtpro.sh.txt against the
upstreadm adtpro.sh script.  Ours had mixed coding styles, and I figured
having to diff with whitespace ignored was a better solution than
dealing with mixed styles either in the file or in the tree for the
majority of people who aren't likely using the same editor I am.
2015-10-30 05:52:22 -07:00

53 lines
1.4 KiB
Bash

#! /bin/bash
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
if [[ ! $(dpkg -l irssi 2> /dev/null | grep '^ii') ]]; then
echo "Installing irssi..."
supo apt-get -y update
sudo apt-get -y install irssi &> /dev/null
sudo apt-get -y clean
fi
if [[ $1 == "-n" && $2 ]]; then
nickname=$2
elif [[ $1 == "-n" ]]; then
nickname="0"
elif [[ -f ~/.irssi/a2c.nickname ]]; then
nickname=$(cat ~/.irssi/a2c.nickname)
else
nickname=
fi
while [[ ! $nickname || ! $(grep -i '^[a-z_\-\\^{}|`][a-z0-9_\-\\^{}|`]*$' <<< $nickname) ]]; do
echo -n "Enter a nickname for chat (to change later, use 'a2chat -n'): "
read
nickname=$REPLY
done
mkdir -p ~/.irssi
echo $nickname > ~/.irssi/a2c.nickname
if [[ -f ~/.irssi/startup ]]; then
mv ~/.irssi/startup ~/.irssi/startup.orig
fi
# SOME broken versions of bash have an intentionally broken
# echo -e for no justifiable reason. Yes I mean YOU, Apple!
echo "/network add -autosendcmd '/join #a2c.chat' Palomino.A2
/server add -auto -network Palomino.A2 irc.a2central.com\n" > ~/.irssi/startup
if [[ -f ~/.irssi/config ]]; then
cp ~/.irssi/config ~/.irssi/config.orig
fi
irssi -n $nickname
rm ~/.irssi/startup &> /dev/null
if [[ -f ~/.irssi/startup.orig ]]; then
mv ~/.irssi/startup.orig ~/.irssi/startup
fi
rm ~/.irssi/config &> /dev/null
if [[ -f ~/.irssi/config.orig ]]; then
mv ~/.irssi/config.orig ~/.irssi/config
fi