diff options
author | Georg | 2021-09-26 16:34:31 +0200 |
---|---|---|
committer | Georg | 2021-09-26 16:34:31 +0200 |
commit | 8e1b0658fd6fad08fa572bbbbdabc080e1bdafe4 (patch) | |
tree | a594fc0bc83aa4a3b7864634f61ea471ec648020 | |
parent | 6a0442c8f227ab624fc92271ee6836a4929e8c8b (diff) | |
download | pounce-8e1b0658fd6fad08fa572bbbbdabc080e1bdafe4.tar.gz pounce-8e1b0658fd6fad08fa572bbbbdabc080e1bdafe4.tar.bz2 pounce-8e1b0658fd6fad08fa572bbbbdabc080e1bdafe4.zip |
First usable release
Signed-off-by: Georg <georg@lysergic.dev>
-rwxr-xr-x | pounceman.sh | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/pounceman.sh b/pounceman.sh index fb1beeb..2a97e5b 100755 --- a/pounceman.sh +++ b/pounceman.sh @@ -50,7 +50,10 @@ get_networks() { 2>&1 1>&3) exit_status=$? case $exit_status in - 0) edit_network "enabled" + 0) + if [ ! $user_choice = "" ]; then + edit_network "enabled" + fi ;; 3) set_network "enabled" ;; @@ -66,7 +69,10 @@ get_networks() { 2>&1 1>&3) exit_status=$? case $exit_status in - 0) edit_network "disabled" + 0) + if [ ! $user_choice = "" ]; then + edit_network "disabled" + fi ;; 3) set_network "disabled" ;; @@ -89,7 +95,7 @@ edit_network() { nw_name=$user_choice nw_hostname=$(egrep '(^|\s)host =' $tmpfile | sed 's/host = //' - ) nw_nickname=$(egrep '(^|\s)nick =' $tmpfile | sed 's/nick = //' - ) - nw_password=$(egrep '(^|\s)sasl-plain =' $tmpfile | sed 's/sasl-plain = //' - ) + nw_password=$(egrep '(^|\s)sasl-plain =' $tmpfile | sed 's/^sasl-plain = [^:]*://' - ) nw_channels=$(egrep '(^|\s)join =' $tmpfile | sed 's/join = //' - ) 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 @@ -103,7 +109,7 @@ edit_network() { 15 60 0 \ "Hostname:" 1 1 "$nw_hostname" 1 18 33 0 \ "Nickname:" 2 1 "$nw_nickname" 2 18 33 0 \ - "SASL Password:" 3 1 "$nw_password" 3 18 33 0 \ + "SASL Password:" 3 1 "$nw_password" 3 18 33 128 \ "Channels:" 4 1 "$nw_channels" 4 18 33 0 \ "Away message:" 5 1 "$nw_away" 5 18 33 0 \ 2>&1 1>&3) @@ -123,7 +129,7 @@ edit_network() { sed -e "s/$(egrep '(^|\s)nick =' $tmpfile)/nick = $tmp_nickname/" -i $tmpfile sed -e "s+$(egrep '(^|\s)real =' $tmpfile)+real = $tmp_nickname - https://liberta.casa/+" -i $tmpfile 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)sasl-plain =' $tmpfile)/sasl-plain = $tmp_nickname:$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 DIFF=$(diff $pouncedir/users/$USER/$1/$user_choice $tmpfile) @@ -153,10 +159,12 @@ edit_network() { } set_network() { - if [ $1 = "disabled" ]; then + if [[ $1 = "disabled" ]] && [[ $user_choice != "" ]]; then mv $pouncedir/users/$USER/disabled/$user_choice $pouncedir/users/$USER/enabled/$user_choice + systemctl --user enable --now pounce@$user_choice fi - if [ $1 = "enabled" ]; then + if [[ $1 = "enabled" ]] && [[ $user_choice != "" ]]; then + systemctl --user disable --now pounce@$user_choice mv $pouncedir/users/$USER/enabled/$user_choice $pouncedir/users/$USER/disabled/$user_choice fi $user_choice="" @@ -179,6 +187,7 @@ add_network() { tmp_password="" tmp_channels="" tmp_away="" + initnew="" while [[ -z $tmp_name || -z $tmp_hostname || -z $tmp_nickname || -z $tmp_password || -z $tmp_channels || -z $tmp_away ]]; do exec 3>&1 user_input=$(dialog --ok-label "Submit" \ @@ -189,11 +198,15 @@ add_network() { "Arbitrary name:" 1 1 "$tmp_name" 1 18 33 0 \ "Hostname:" 2 1 "$tmp_hostname" 2 18 33 0 \ "Nickname:" 3 1 "$tmp_nickname" 3 18 33 0 \ - "SASL Password:" 4 1 "$tmp_password" 4 18 33 0 \ + "SASL Password:" 4 1 "$tmp_password" 4 18 33 128 \ "Channels:" 5 1 "$tmp_channels" 5 18 33 0 \ "Away message:" 6 1 "$tmp_away" 6 18 33 0 \ 2>&1 1>&3) #3>&1 1>&2 2>&3 3>&-) + if [ "$?" = "1" ]; then + initnew="false" + break + fi exec 3>&- echo $user_input > /tmp/userinput tmp_name=$(echo "$user_input" | sed -n 1p) @@ -203,7 +216,7 @@ add_network() { tmp_channels=$(echo "$user_input" | sed -n 5p) tmp_away=$(echo "$user_input" | sed -n 6p) done - if [ ! $tmp_name = "TEMPLATE" ]; then + if [[ $tmp_name != "TEMPLATE" ]] && [[ $initnew != "false" ]]; 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/%%USER%%/$USER/" -i $pouncedir/users/$USER/disabled/$tmp_name |