scripts now runnable

This commit is contained in:
sose 2020-06-14 23:19:28 +00:00
parent 84c685912b
commit 621066005c
3 changed files with 15 additions and 6 deletions

View File

@ -25,7 +25,7 @@ attatch_tmux_session() {
session_name=""
window_number=""
echo "Attatching to existing tmux session..."
if [ "$(tmux list-sessions | wc -l)" != "1" ]
if tmux list-sessions >/dev/null
then
tmux_sessions="$(tmux list-sessions \
| cut -f 1 -d ' ' \
@ -73,7 +73,7 @@ create_weechat_relay(){
| grep "$weechat_pane_name" \
| cut -f 1 -d ' ')"
if [ "$weechat_pane_id" == " " ]
if [ "$weechat_pane_id" = " " ]
then
echo "Failed to find WeeChat session, exiting..."
exit

15
irc.sh
View File

@ -4,6 +4,7 @@ set_relay_config(){
weechat_relay_port=""
weechat_relay_password=""
relay_type="$1"
temp_file_name=""
while :
do
echo "Enter relay port number (leave blank for default 9000)"
@ -15,7 +16,7 @@ set_relay_config(){
break
fi
if [ "$relay_type" == "new" ] && "$ssh_command grep -w $weechat_relay_port /etc/services"
if [ "$relay_type" = "new" ] && "$ssh_command grep -w $weechat_relay_port /etc/services"
then
echo "Port $weechat_relay_port is in use, try another port"
else
@ -58,11 +59,17 @@ set_relay_config(){
echo "port = $weechat_relay_port" > ./.qweechat.conf
echo "server = $tilde_name" > ./.qweechat.conf
scp -ni "$key_file" ./.qweechat.conf "$tilde_username@$tilde_name:./"
scp -i "$key_file" ./.qweechat.conf "$tilde_username@$tilde_name:./"
if [ "$relay_type" == "new" ]
if [ "$relay_type" = "new" ]
then
temp_file_name=".$(shuf -i 0-100000 -n 1).temp"
echo "Since you do not have an existing WeeChat relay, a new one will be configured for you"
echo "weechat_relay_port=\"$weechat_relay_port\" weechat_relay_password=\"$weechat_relay_password\" $(cat ./util.sh ./configure_weechat_session.sh)" | "$ssh_command -t -t"
echo "weechat_relay_port=\"$weechat_relay_port\" weechat_relay_password=\"$weechat_relay_password\" $(cat ./util.sh ./configure_weechat_session.sh)" > $temp_file_name
scp -i "$key_file" "$temp_file_name" "$tilde_username@$tilde_name:./"
ssh_command="$ssh_command -t -t"
$ssh_command "sh $temp_file_name"
#$ssh_command "rm ./$temp_file_name"
rm "$temp_file_name"
fi
}

View File

@ -45,12 +45,14 @@ do
"1")
clear
set_relay_config "existing"
break
;;
"2")
clear
echo "Since no WeeChat relay exists, a new one will be configured"
echo "First, provide a port number and password for this relay"
set_relay_config "new"
break
;;
"*")
echo "Please enter a valid option"