Subversion Repositories ALCASAR

Rev

Rev 3313 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3313 Rev 3318
Line 86... Line 86...
86
	if [ $# -ne 1 ]
86
	if [ $# -ne 1 ]
87
	then
87
	then
88
		echo "error: need to pass remote name"
88
		echo "error: need to pass remote name"
89
		return 1
89
		return 1
90
	fi
90
	fi
91
 
-
 
92
	name="$1"
91
	name="$1"
-
 
92
	# Check for replication
-
 
93
	attributes="$(/usr/local/bin/alcasar-replication-list.sh --name=$name)"
-
 
94
	if ! echo "$attributes" | grep -q "Master_Host"; then
-
 
95
		echo "no repliqua to $name"
-
 
96
		return 1
-
 
97
	fi
93
	echo "Stop slave in '$name'..."
98
	echo "Stop slave in '$name'..."
94
	exec_query "STOP SLAVE '$name'" || return
99
	exec_query "STOP SLAVE '$name'" || return
95
 
-
 
96
	echo "Resetting replication with '$name'..."
100
	echo "Resetting replication with '$name'..."
97
	exec_query "RESET REPLICA '$name' ALL" || return
101
	exec_query "RESET REPLICA '$name' ALL" || return
98
 
-
 
99
	echo "Deleting SSH tunnel with '$name'..."
-
 
100
	service_file="replication-$name.service"
102
	service_file="replication-$name.service"
101
	service_path="/etc/systemd/system/$service_file"
103
	service_path="/etc/systemd/system/$service_file"
102
	[ -f "$service_path" ] && systemctl stop "$service_file" && systemctl disable "$service_file"
104
	if [ -f "$service_path" ]; then # for slaves only
103
	
-
 
104
	# Get remote IP and port from its name
105
		echo "Deleting SSH tunnel with '$name'..."
-
 
106
		systemctl stop "$service_file"
-
 
107
		systemctl disable "$service_file"
105
	port="$(grep "ExecStart" "$service_path" | cut -d ' ' -f 9)"
108
		port="$(grep "ExecStart" "$service_path" | cut -d ' ' -f 9)"
106
	ip="$(grep "ExecStart" "$service_path" | cut -d ' ' -f 14 | cut -d '@' -f2)"
109
		ip="$(grep "ExecStart" "$service_path" | cut -d ' ' -f 14 | cut -d '@' -f2)"
-
 
110
		rm "$service_path"
107
	echo "Disabling outbound connection to remote SSH ($ip:$port)"
111
		echo "Disabling outbound connection to remote SSH ($ip:$port)"
108
	sed -i "/^REPLICATION_TO=/s/$ip:$port,//" /usr/local/etc/alcasar.conf
112
		sed -i "/^REPLICATION_TO=/s/$ip:$port,//" /usr/local/etc/alcasar.conf
109
	/usr/local/bin/alcasar-iptables.sh
113
		/usr/local/bin/alcasar-iptables.sh
110
	rm "$service_path"
114
	fi
111
}
115
}
112
 
116
 
113
# Print help message
117
# Print help message
114
usage() {
118
usage() {
115
	echo "usage: $0 OPTIONS"
119
	echo "usage: $0 OPTIONS"