a2cloud/setup/a2chat

73 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2015-10-30 12:34:48 +00:00
#! /bin/bash
2016-10-25 17:42:29 +00:00
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
2015-10-30 11:48:33 +00:00
# a2chat - a2cloud irc client wrapper
#
# To the extent possible under law, T. Joseph Carter and Ivan Drucker have
# waived all copyright and related or neighboring rights to the a2cloud
# scripts themselves. Software used or installed by these scripts is subject
# to other licenses. This work is published from the United States.
2015-10-30 11:48:33 +00:00
if [[ ! $(dpkg -l irssi 2> /dev/null | grep '^ii') ]]; then
2016-10-25 17:42:29 +00:00
echo "Installing irssi..."
sudo apt-get -y update
2016-10-25 17:42:29 +00:00
sudo apt-get -y install irssi &> /dev/null
sudo apt-get -y clean
2015-10-30 12:38:31 +00:00
fi
2015-10-30 11:48:33 +00:00
if [[ $1 == "-n" && $2 ]]; then
2016-10-25 17:42:29 +00:00
nickname=$2
2015-10-30 11:48:33 +00:00
elif [[ $1 == "-n" ]]; then
2016-10-25 17:42:29 +00:00
nickname="0"
2015-10-30 11:48:33 +00:00
elif [[ -f ~/.irssi/a2c.nickname ]]; then
2016-10-25 17:42:29 +00:00
nickname=$(cat ~/.irssi/a2c.nickname)
2015-10-30 11:48:33 +00:00
else
2016-10-25 17:42:29 +00:00
nickname=
2015-10-30 11:48:33 +00:00
fi
while [[ ! $nickname || ! $(grep -i '^[a-z_\-\\^{}|`][a-z0-9_\-\\^{}|`]*$' <<< $nickname) ]]; do
2016-10-25 17:42:29 +00:00
echo "Choosing a nickname"
echo
echo "A nickname on irc is how you are known to other people. It can"
echo "consist of letters, numbers, and punctuation symbols such as -, _, and ^."
echo "Some older IRC servers will cut your nickname to eight characters, but"
echo "more modern ones like A2Central do not."
echo
echo "Aliases are fine on irc, but really common names like James or Mark or"
echo "AppleIIGuy are likely to be used by someone else already. A guy named"
echo "Joseph might use some variation of their name (such as JosephC or"
echo "tjcarter) or come up with something else entirely."
echo
echo "You can change your nickname once you're online by typing a command"
echo "like \"/nick <newnick>\", and you can rerun this script with the -n"
echo "parameter to have this script save your choice for future use."
echo
echo -n "Enter a nickname (use 'a2chat -n' to change it later): "
read
nickname=$REPLY
2015-10-30 11:48:33 +00:00
done
mkdir -p ~/.irssi
echo $nickname > ~/.irssi/a2c.nickname
if [[ -f ~/.irssi/startup ]]; then
2016-10-25 17:42:29 +00:00
mv ~/.irssi/startup ~/.irssi/startup.orig
2015-10-30 11:48:33 +00:00
fi
2016-07-21 06:44:19 +00:00
echo -e "/network add -autosendcmd '/join #a2c.chat' Palomino.A2\n/server add -auto -network Palomino.A2 irc.a2central.com\n" > ~/.irssi/startup
2015-10-30 11:48:33 +00:00
if [[ -f ~/.irssi/config ]]; then
2016-10-25 17:42:29 +00:00
cp ~/.irssi/config ~/.irssi/config.orig
2015-10-30 11:48:33 +00:00
fi
irssi -n $nickname
rm ~/.irssi/startup &> /dev/null
if [[ -f ~/.irssi/startup.orig ]]; then
2016-10-25 17:42:29 +00:00
mv ~/.irssi/startup.orig ~/.irssi/startup
2015-10-30 11:48:33 +00:00
fi
rm ~/.irssi/config &> /dev/null
if [[ -f ~/.irssi/config.orig ]]; then
2016-10-25 17:42:29 +00:00
mv ~/.irssi/config.orig ~/.irssi/config
2015-10-30 11:48:33 +00:00
fi