emq-TE1/install/move_nmconnection.sh

33 lines
1.2 KiB
Bash

#!/bin/bash
### BEGIN INIT INFO
# Provides: move_nmconnection.sh
# Required-Start: $network $local_fs $remote_fs $syslog
# Required-Stop: $network $local_fs $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Move and configure NetworkManager connections
# Description: Moves the .nmconnection files from /boot to /etc/NetworkManager/system-connections and restarts NetworkManager.
### END INIT INFO
# Directorio de la partición boot
BOOT_DIR="/boot"
# Directorio de destino para los archivos de configuración de NetworkManager
DEST_DIR="/etc/NetworkManager/system-connections"
# Buscar archivos .nmconnection en /boot y moverlos a /etc/NetworkManager/system-connections/
for nm_file in $BOOT_DIR/*.nmconnection; do
if [ -f "$nm_file" ]; then
# Mover el archivo .nmconnection a la carpeta de configuración de NetworkManager
mv "$nm_file" "$DEST_DIR/"
# Asegurarse de que los permisos sean correctos (solo lectura para root)
chmod 600 "$DEST_DIR/$(basename $nm_file)"
fi
done
# Detener NetworkManager
sudo systemctl stop NetworkManager
# Iniciar NetworkManager
sudo systemctl start NetworkManager