#!/bin/sh 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)" read -r weechat_relay_port if [ -z "$weechat_relay_port" ] then weechat_relay_port="9000" break fi 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 break fi if [ "$weechat_relay_port" -gt 1023 ] then break else echo "Please enter a port number > 1023" fi done while : do echo "Enter a password for this relay:" stty -echo read -r weechat_relay_password stty echo echo "Re-enter password:" stty -echo read -r weechat_relay_confirm_password stty echo if [ "$weechat_relay_password" = "$weechat_relay_confirm_password" ] then break else echo "Passwords do not match" fi done echo "Writing to qWeeChat config..." echo "[relay]" > ./.qweechat.conf echo "lines = 50" > ./.qweechat.conf echo "autoconnect = off" > ./.qweechat.conf echo "password = $weechat_relay_password" > ./.qweechat.conf echo "ssl = off" > ./.qweechat.conf echo "port = $weechat_relay_port" > ./.qweechat.conf echo "server = $tilde_name" > ./.qweechat.conf echo "Copying qWeeChat config..." # scp -i "$key_file" ./.qweechat.conf "$tilde_username@$tilde_name:./" if [ "$relay_type" = "new" ] then temp_file_name=".$(shuf -i 0-100000 -n 1).temp" echo "Configuring WeeChat on remote host..." echo "weechat_relay_port=\"$weechat_relay_port\" weechat_relay_password=\"$weechat_relay_password\" $(cat ./util.sh ./configure_weechat_session.sh)" > $temp_file_name echo "Copying setup scripts to remote host..." scp -i "$key_file" "$temp_file_name" "$tilde_username@$tilde_name:./" ssh_command="$ssh_command -t -t" echo "Running setup scripts..." $ssh_command "sh $temp_file_name" echo "Cleaning up on remote host..." $ssh_command "rm ./$temp_file_name" rm "$temp_file_name" fi }