#!/usr/bin/env bash

wlandev=wlan0
wifidev=`ifconfig ra0 2>/dev/null | grep ra0 | wc -l`
if [[ $wifidev == 1 ]]; then
	wlandev=ra0
fi


SERVICE_NAME=wpa_supplicant@$wlandev

systemctl stop $SERVICE_NAME

systemctl is-enabled $SERVICE_NAME > /dev/null
[[ $? == 0 ]] && # 1 - disabled
	systemctl disable $SERVICE_NAME &&
	echo "WiFi $SERVICE_NAME service disabled" &&
        [[ -e /etc/netplan/01-wifi-$wlandev.yaml ]] && rm /etc/netplan/01-wifi-$wlandev.yaml
