70 lines
2.3 KiB
Bash
Executable File
70 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function prompt-var() {
|
|
if [ -z "$1" ] || [ -z "$2" ]; then
|
|
echo "Need a variable name (1) and a prompt string (2)"
|
|
return 1;
|
|
fi
|
|
unset $1
|
|
while [ "${!1}" == "" ]; do
|
|
printf "%s " "$2";
|
|
read $1;
|
|
done
|
|
return 0;
|
|
}
|
|
# This function will prompt the user for variable 1 with string 2 until it gets a nonempty answer.
|
|
function prompt-password() {
|
|
if [ -z "$1" ] || [ -z "$2" ]; then
|
|
echo "Need a variable name (1) and a prompt string (2)"
|
|
return 1;
|
|
fi
|
|
unset $1
|
|
while [ "${!1}" == "" ]; do
|
|
printf "%s " "$2";
|
|
read -s $1;
|
|
echo
|
|
done
|
|
return 0;
|
|
}
|
|
#This function will prompt the user for a variable 1 with string 2 until it gets an answer between min 3 and max 4.
|
|
function prompt-num-var() {
|
|
if [ -z "$1" ] || [ -z "$2" ] || [ "$3" -ne "$3" ] || [ "$4" -le "$3" ]; then
|
|
echo "Need a variable name (1), prompt string (2), min (3), and max (4)";
|
|
echo 1: $1;
|
|
echo 2: $2;
|
|
echo 3: $3;
|
|
echo 4: $4;
|
|
return 1;
|
|
fi
|
|
unset $1
|
|
while [ "${!1}" == "" ] || [ "${!1}" -lt "$3" ] || [ "${!1}" -gt "$4" ]; do
|
|
printf "%s " "$2";
|
|
read $1;
|
|
done
|
|
return 0;
|
|
}
|
|
# Needed information
|
|
prompt-var NETWORKNAME "What is the network name? "
|
|
prompt-var IRCADDRESS "What is the IRC address? "
|
|
prompt-num-var IRCPORT "What port is listening? " 1 65535
|
|
prompt-var CHANNELNAME "What is the first channel to join? "
|
|
prompt-var USERNAME "What username do you use on this network? "
|
|
prompt-password NICKSERVPASS "What is your password to NickServ?"
|
|
prompt-password SERVERPASS "What is the server password? (Enter nopass if no password)"
|
|
|
|
# Create the config;
|
|
cp -r /etc/skel/.irssi ./.irssi-"$NETWORKNAME"
|
|
cd ./.irssi-"$NETWORKNAME"
|
|
if [ "$SERVERPASS" != "nopass" ]; then
|
|
sed -i "s@address = \"IRCADDRESS\";@address = \"IRCADDRESS\";\n password = \"$SERVERPASS\";@" config
|
|
fi
|
|
sed -i "s@NETWORKNAME@$NETWORKNAME@g" config
|
|
sed -i "s@IRCADDRESS@$IRCADDRESS@g" config
|
|
sed -i "s@IRCPORT@$IRCPORT@g" config
|
|
sed -i "s@CHANNELNAME@$CHANNELNAME@g" config
|
|
sed -i "s@USERNAME@$USERNAME@g" config
|
|
sed -i "s@REALNAME@$USERNAME@g" config
|
|
sed -i "s@NICKSERVPASS@$NICKSERVPASS@g" config
|
|
echo
|
|
echo "Run \"irssi --home=$PWD\" to start your new config."
|