Update move_nmconnection.sh

This commit is contained in:
Esteban Mackay Q. 2024-12-13 10:55:25 -05:00
parent 165ba8a4a3
commit 9523429421
1 changed files with 8 additions and 2 deletions

View File

@ -12,11 +12,17 @@
BOOT_DIR="/boot"
DEST_DIR="/etc/NetworkManager/system-connections"
# Verificar si hay archivos .nmconnection en /boot
if ! ls "$BOOT_DIR"/*.nmconnection &>/dev/null; then
echo "No se encontraron archivos .nmconnection en $BOOT_DIR. Saliendo..."
exit 0
fi
get_ssid_from_file() {
grep -oP '^ssid=\K.*' "$1"
}
for nm_file in $BOOT_DIR/*.nmconnection; do
for nm_file in "$BOOT_DIR"/*.nmconnection; do
if [ -f "$nm_file" ]; then
new_ssid=$(get_ssid_from_file "$nm_file")
if [ -z "$new_ssid" ]; then
@ -31,7 +37,7 @@ for nm_file in $BOOT_DIR/*.nmconnection; do
done
fi
mv -f "$nm_file" "$DEST_DIR/"
chmod 600 "$DEST_DIR/$(basename $nm_file)"
chmod 600 "$DEST_DIR/$(basename "$nm_file")"
fi
done