First usable release

Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
Georg Pfuetzenreuter 2021-09-26 16:34:31 +02:00
parent 6a0442c8f2
commit 8e1b0658fd
Signed by: Georg
GPG Key ID: 1DAF57F49F8E8F22

View File

@ -50,7 +50,10 @@ get_networks() {
2>&1 1>&3) 2>&1 1>&3)
exit_status=$? exit_status=$?
case $exit_status in case $exit_status in
0) edit_network "enabled" 0)
if [ ! $user_choice = "" ]; then
edit_network "enabled"
fi
;; ;;
3) set_network "enabled" 3) set_network "enabled"
;; ;;
@ -66,7 +69,10 @@ get_networks() {
2>&1 1>&3) 2>&1 1>&3)
exit_status=$? exit_status=$?
case $exit_status in case $exit_status in
0) edit_network "disabled" 0)
if [ ! $user_choice = "" ]; then
edit_network "disabled"
fi
;; ;;
3) set_network "disabled" 3) set_network "disabled"
;; ;;
@ -89,7 +95,7 @@ edit_network() {
nw_name=$user_choice nw_name=$user_choice
nw_hostname=$(egrep '(^|\s)host =' $tmpfile | sed 's/host = //' - ) nw_hostname=$(egrep '(^|\s)host =' $tmpfile | sed 's/host = //' - )
nw_nickname=$(egrep '(^|\s)nick =' $tmpfile | sed 's/nick = //' - ) 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_channels=$(egrep '(^|\s)join =' $tmpfile | sed 's/join = //' - )
nw_away=$(egrep '(^|\s)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 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 \ 15 60 0 \
"Hostname:" 1 1 "$nw_hostname" 1 18 33 0 \ "Hostname:" 1 1 "$nw_hostname" 1 18 33 0 \
"Nickname:" 2 1 "$nw_nickname" 2 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 \ "Channels:" 4 1 "$nw_channels" 4 18 33 0 \
"Away message:" 5 1 "$nw_away" 5 18 33 0 \ "Away message:" 5 1 "$nw_away" 5 18 33 0 \
2>&1 1>&3) 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)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)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)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)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) DIFF=$(diff $pouncedir/users/$USER/$1/$user_choice $tmpfile)
@ -153,10 +159,12 @@ edit_network() {
} }
set_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 mv $pouncedir/users/$USER/disabled/$user_choice $pouncedir/users/$USER/enabled/$user_choice
systemctl --user enable --now pounce@$user_choice
fi 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 mv $pouncedir/users/$USER/enabled/$user_choice $pouncedir/users/$USER/disabled/$user_choice
fi fi
$user_choice="" $user_choice=""
@ -179,6 +187,7 @@ add_network() {
tmp_password="" tmp_password=""
tmp_channels="" tmp_channels=""
tmp_away="" tmp_away=""
initnew=""
while [[ -z $tmp_name || -z $tmp_hostname || -z $tmp_nickname || -z $tmp_password || -z $tmp_channels || -z $tmp_away ]]; do while [[ -z $tmp_name || -z $tmp_hostname || -z $tmp_nickname || -z $tmp_password || -z $tmp_channels || -z $tmp_away ]]; do
exec 3>&1 exec 3>&1
user_input=$(dialog --ok-label "Submit" \ user_input=$(dialog --ok-label "Submit" \
@ -189,11 +198,15 @@ add_network() {
"Arbitrary name:" 1 1 "$tmp_name" 1 18 33 0 \ "Arbitrary name:" 1 1 "$tmp_name" 1 18 33 0 \
"Hostname:" 2 1 "$tmp_hostname" 2 18 33 0 \ "Hostname:" 2 1 "$tmp_hostname" 2 18 33 0 \
"Nickname:" 3 1 "$tmp_nickname" 3 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 \ "Channels:" 5 1 "$tmp_channels" 5 18 33 0 \
"Away message:" 6 1 "$tmp_away" 6 18 33 0 \ "Away message:" 6 1 "$tmp_away" 6 18 33 0 \
2>&1 1>&3) 2>&1 1>&3)
#3>&1 1>&2 2>&3 3>&-) #3>&1 1>&2 2>&3 3>&-)
if [ "$?" = "1" ]; then
initnew="false"
break
fi
exec 3>&- exec 3>&-
echo $user_input > /tmp/userinput echo $user_input > /tmp/userinput
tmp_name=$(echo "$user_input" | sed -n 1p) tmp_name=$(echo "$user_input" | sed -n 1p)
@ -203,7 +216,7 @@ add_network() {
tmp_channels=$(echo "$user_input" | sed -n 5p) tmp_channels=$(echo "$user_input" | sed -n 5p)
tmp_away=$(echo "$user_input" | sed -n 6p) tmp_away=$(echo "$user_input" | sed -n 6p)
done done
if [ ! $tmp_name = "TEMPLATE" ]; then if [[ $tmp_name != "TEMPLATE" ]] && [[ $initnew != "false" ]]; then
cp $pouncedir/TEMPLATE $pouncedir/users/$USER/disabled/$tmp_name 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/%%USER%%/$USER/" -i $pouncedir/users/$USER/disabled/$tmp_name