2022-02-12 23:11:35 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-12-18 11:34:44 +01:00
|
|
|
# Get DataDir location
|
|
|
|
DATA_DIR="/mnt/data"
|
|
|
|
case "$(ubnt-device-info firmware || true)" in
|
2023-02-27 13:16:52 +02:00
|
|
|
1*)
|
|
|
|
DATA_DIR="/mnt/data"
|
|
|
|
;;
|
|
|
|
2*)
|
|
|
|
DATA_DIR="/data"
|
|
|
|
;;
|
|
|
|
3*)
|
|
|
|
DATA_DIR="/data"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: No persistent storage found." 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2022-12-18 11:34:44 +01:00
|
|
|
|
|
|
|
user_authorized_keys_file="$DATA_DIR/ssh/authorized_keys"
|
2022-02-12 23:11:35 +02:00
|
|
|
udm_authorized_keys_file="/root/.ssh/authorized_keys"
|
|
|
|
|
2022-12-18 11:34:44 +01:00
|
|
|
# if $DATA_DIR/ssh/authorized_keys is missing print error message
|
2022-02-12 23:11:35 +02:00
|
|
|
if [ ! -f "$user_authorized_keys_file" ]; then
|
|
|
|
echo "ERROR: $user_authorized_keys_file is missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-02-27 13:22:22 +02:00
|
|
|
# Overwrite /root/.ssh/authorized_keys with $DATA_DIR/ssh/authorized_keys
|
|
|
|
echo "$(cat "$user_authorized_keys_file")" >"$udm_authorized_keys_file"
|
2022-02-12 23:11:35 +02:00
|
|
|
|
|
|
|
exit 0
|