2023-08-07 00:30:11 +00:00
|
|
|
#!/bin/sh
|
2022-02-05 14:23:32 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
2023-08-07 00:30:11 +00:00
|
|
|
# Minimal OS variable loading for performance
|
2023-09-04 10:46:11 +00:00
|
|
|
. /etc/profile.d/001-functions
|
2022-02-05 14:23:32 +00:00
|
|
|
|
2023-04-22 20:01:07 +00:00
|
|
|
tocon "Setting root password..."
|
|
|
|
|
2022-02-11 20:01:14 +00:00
|
|
|
if [ ! -d "/storage/.cache/samba" ]
|
|
|
|
then
|
|
|
|
mkdir -p /storage/.cache/samba
|
|
|
|
touch /storage/.cache/samba/smbpasswd
|
|
|
|
fi
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
ROTATION=$(get_setting rotate.root.password)
|
|
|
|
if [ "${ROTATION}" == "0" ]
|
|
|
|
then
|
2023-04-13 23:19:05 +00:00
|
|
|
ROOTPASS=$(get_setting root.password)
|
|
|
|
setrootpass "${ROOTPASS}"
|
2022-02-05 14:23:32 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Randomly generate the root password on startup
|
|
|
|
ROOTPASS=$(openssl rand -base64 10 2>/dev/null | sed "s#==##g")
|
|
|
|
|
2022-03-09 02:07:12 +00:00
|
|
|
/usr/bin/setrootpass "${ROOTPASS}"
|