From b400bbafb262879298035402b8ac35ac82a012a2 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Fri, 18 Nov 2016 15:01:36 -0600 Subject: [PATCH] Should include this since irssi is a ShadowArch default --- Shared/Makefile | 2 +- Shared/new-irssi-config | 69 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 Shared/new-irssi-config diff --git a/Shared/Makefile b/Shared/Makefile index 32f1063..1d221cb 100644 --- a/Shared/Makefile +++ b/Shared/Makefile @@ -1,4 +1,4 @@ -LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip +LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip new-irssi-config LOCATION=/usr/local/bin PERMISSION=0755 compile: diff --git a/Shared/new-irssi-config b/Shared/new-irssi-config new file mode 100755 index 0000000..441af5e --- /dev/null +++ b/Shared/new-irssi-config @@ -0,0 +1,69 @@ +#!/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."