summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpounceman.sh79
1 files changed, 44 insertions, 35 deletions
diff --git a/pounceman.sh b/pounceman.sh
index 180b36e..4c32ecd 100755
--- a/pounceman.sh
+++ b/pounceman.sh
@@ -3,16 +3,8 @@
DIALOG_CANCEL=1
DIALOG_ESC=255
DIALOG_EXTRA=3
-HEIGHT=0
-WIDTH=0
pouncedir="/var/lib/pounce"
-display_result() {
- dialog --title "$1" \
- --no-collapse \
- --msgbox "$result" 0 0
-}
-
menu() {
exec 3>&1
selection=$(dialog \
@@ -20,7 +12,7 @@ menu() {
--title "Welcome!" \
--clear \
--cancel-label "Exit" \
- --menu "Please select:" $HEIGHT $WIDTH 4 \
+ --menu "Configure your IRC bouncer:" 0 0 8 \
"1" "Display active networks" \
"2" "Display disabled networks" \
"3" "Add new network" \
@@ -48,17 +40,35 @@ get_networks() {
done
if [ $1 = "enabled" ]; then
user_choice=$(dialog --ok-label "Edit" \
+ --extra-button \
+ --extra-label "Disable" \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--radiolist "Networks" 0 0 $COUNTER \
$RADIOLIST \
2>&1 1>&3)
+ exit_status=$?
+ case $exit_status in
+ 0) edit_network "enabled"
+ ;;
+ 3) set_network "enabled"
+ ;;
+ esac
fi
if [ $1 = "disabled" ]; then
user_choice=$(dialog --ok-label "Edit" \
+ --extra-button \
+ --extra-label "Enable" \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--radiolist "Networks" 0 0 $COUNTER \
$RADIOLIST \
2>&1 1>&3)
+ exit_status=$?
+ case $exit_status in
+ 0) edit_network "disabled"
+ ;;
+ 3) set_network "disabled"
+ ;;
+ esac
fi
exec 3>&-
echo $user_choice > /tmp/userchoice
@@ -79,7 +89,7 @@ edit_network() {
nw_nickname=$(egrep '(^|\s)nick =' $tmpfile | sed 's/nick = //' - )
nw_password=$(egrep '(^|\s)sasl-plain =' $tmpfile | sed 's/sasl-plain = //' - )
nw_channels=$(egrep '(^|\s)join =' $tmpfile | sed 's/join = //' - )
- nw_away=$(grep 'away' $tmpfile | sed 's/away = //' -)
+ nw_away=$(egrep '(^|\s)away =' $tmpfile | sed 's/away = //' -)
echo "$nw_hostname\n$nw_nickname\n$nw_password\n$nw_channels\n$nw_away" > /tmp/nwvars
exec 3>&1
user_input=$(dialog --ok-label "Save" \
@@ -100,12 +110,12 @@ edit_network() {
echo $user_input > /tmp/userinput
case $exit_status in
0)
- tmp_name=$(echo "$user_input" | sed -n 1p)
- tmp_hostname=$(echo "$user_input" | sed -n 2p)
- tmp_nickname=$(echo "$user_input" | sed -n 3p)
- tmp_password=$(echo "$user_input" | sed -n 4p)
- tmp_channels=$(echo "$user_input" | sed -n 5p)
- tmp_away=$(echo "$user_input" | sed -n 6p)
+ #tmp_name=$(echo "$user_input" | sed -n 1p)
+ tmp_hostname=$(echo "$user_input" | sed -n 1p)
+ tmp_nickname=$(echo "$user_input" | sed -n 2p)
+ tmp_password=$(echo "$user_input" | sed -n 3p)
+ tmp_channels=$(echo "$user_input" | sed -n 4p)
+ tmp_away=$(echo "$user_input" | sed -n 5p)
echo "$tmp_name\n$tmp_nickname\n$tmp_password\n$tmp_channels\n$tmp_away" > /tmp/tmpvars
sed -e "s/$(egrep '(^|\s)host =' $tmpfile)/host = $tmp_hostname/" -i $tmpfile
sed -e "s/$(egrep '(^|\s)nick =' $tmpfile)/nick = $tmp_nickname/" -i $tmpfile
@@ -113,13 +123,16 @@ edit_network() {
sed -e "s/$(egrep '(^|\s)user =' $tmpfile)/user = $tmp_nickname/" -i $tmpfile
sed -e "s/$(egrep '(^|\s)sasl-plain =' $tmpfile)/sasl-plain = $tmp_password/" -i $tmpfile
sed -e "s/$(egrep '(^|\s)join =' $tmpfile)/join = $tmp_channels/" -i $tmpfile
- sed -e "s/$(egrep '(^|\s)away =' $tmpfile)/away = $tmp_away/" -i $tmpfile
+ sed -e "s+$(egrep '(^|\s)away =' $tmpfile)+away = $tmp_away+" -i $tmpfile
DIFF=$(diff $pouncedir/users/$USER/$1/$user_choice $tmpfile)
if [ ! "$DIFF" = "" ]; then
cp $tmpfile $pouncedir/users/$USER/$1/$user_choice
fi
rm $tmpfile
;;
+ 3)
+ remove_network
+ ;;
esac
nw_name=""
nw_hostname=""
@@ -181,10 +194,10 @@ add_network() {
tmp_away=$(echo "$user_input" | sed -n 6p)
if [ ! $tmp_name = "TEMPLATE" ]; then
cp $pouncedir/TEMPLATE $pouncedir/users/$USER/disabled/$tmp_name
- sed -e "s/%%POUNCEDIR%%/$pouncedir/" -i $pouncedir/users/$USER/disabled/$tmp_name
+ sed -e "s+%%POUNCEDIR%%+$pouncedir+" -i $pouncedir/users/$USER/disabled/$tmp_name
sed -e "s/%%USER%%/$USER/" -i $pouncedir/users/$USER/disabled/$tmp_name
sed -e "s/%%NAME%%/$tmp_name/" -i $pouncedir/users/$USER/disabled/$tmp_name
- sed -e "s/%%PASSWORD%%/$tmp_password/" -i $pouncedir/users/$USER/disabled/$tmp_name
+ sed -e "s:%%PASSWORD%%:$tmp_password:" -i $pouncedir/users/$USER/disabled/$tmp_name
sed -e "s/%%HOSTNAME%%/$tmp_hostname/" -i $pouncedir/users/$USER/disabled/$tmp_name
sed -e "s/%%CHANNELS%%/$tmp_channels/" -i $pouncedir/users/$USER/disabled/$tmp_name
sed -e "s/%%USERNAME%%/$tmp_nickname/" -i $pouncedir/users/$USER/disabled/$tmp_name
@@ -208,26 +221,22 @@ while true; do
esac
case $selection in
1 )
- #result=$(ls $pouncedir/users/$USER/enabled/)
- #display_result "Enabled networks:"
get_networks "enabled"
- if [ ! -z "$user_choice" ]; then
- edit_network "enabled"
- if [ $exit_status = $DIALOG_EXTRA ]; then
- remove_network
- fi
- fi
+# if [ ! -z "$user_choice" ]; then
+# edit_network "enabled"
+# if [ $exit_status = $DIALOG_EXTRA ]; then
+# remove_network
+# fi
+# fi
;;
2 )
- #result=$(ls $pouncedir/users/$USER/disabled/)
- #display_result "Disabled networks:"
get_networks "disabled"
- if [ ! -z "$user_choice" ]; then
- edit_network "disabled"
- if [ $exit_status = $DIALOG_EXTRA ]; then
- remove_network
- fi
- fi
+# if [ ! -z "$user_choice" ]; then
+# edit_network "disabled"
+# if [ $exit_status = $DIALOG_EXTRA ]; then
+# remove_network
+# fi
+# fi
;;
3 )
add_network