mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-24 11:46:30 +00:00
add adminpasswd script to conveniently update admin/root password
This commit is contained in:
parent
8556a04e97
commit
217053f76f
@ -51,6 +51,10 @@ case "$1" in
|
||||
touch /data/etc/adjtime
|
||||
sync
|
||||
msg_done
|
||||
|
||||
msg_begin "Setting empty root password"
|
||||
PASSWORD="" adminpasswd
|
||||
msg_done
|
||||
|
||||
# mount other partitions depending on data
|
||||
mount -T /etc/fstab.disk -a
|
||||
|
@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
test -n "$os_version" || source /etc/init.d/base
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
# make sure root and admin users exist in shadow file
|
||||
touch /data/etc/shadow
|
||||
chmod go-rwx /data/etc/shadow
|
||||
if ! grep root /data/etc/shadow &>/dev/null; then
|
||||
echo 'root::::::::' >> /data/etc/shadow
|
||||
fi
|
||||
if ! grep admin /data/etc/shadow &>/dev/null; then
|
||||
echo 'admin::::::::' >> /data/etc/shadow
|
||||
fi
|
||||
|
||||
# remove shadow backups
|
||||
rm -f /data/etc/shadow+
|
||||
rm -f /data/etc/shadow-
|
||||
|
||||
if [ -x /etc/init.d/adminpw ]; then
|
||||
# set root and admin passwords (admin is just an alias for root)
|
||||
password=$(/etc/init.d/adminpw)
|
||||
msg_begin "Setting root password"
|
||||
|
||||
echo -en "$password\n$password\n" | passwd &>/dev/null # root
|
||||
echo -en "$password\n$password\n" | passwd admin &>/dev/null # admin
|
||||
|
||||
sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration
|
||||
sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration
|
||||
msg_done
|
||||
fi
|
||||
|
||||
sync
|
||||
|
||||
;;
|
||||
|
||||
stop)
|
||||
true
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# echo your admin password here
|
||||
|
31
board/common/overlay/usr/sbin/adminpasswd
Executable file
31
board/common/overlay/usr/sbin/adminpasswd
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# we verify the presence of the PASSWORD variable using env,
|
||||
# as it can also have an empty string value
|
||||
if ! env | grep PASSWORD &>/dev/null; then
|
||||
echo "You must set the PASSWORD environment variable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure root and admin users exist in shadow file
|
||||
touch /data/etc/shadow
|
||||
chmod go-rwx /data/etc/shadow
|
||||
if ! grep root /data/etc/shadow &>/dev/null; then
|
||||
echo 'root::::::::' >> /data/etc/shadow
|
||||
fi
|
||||
if ! grep admin /data/etc/shadow &>/dev/null; then
|
||||
echo 'admin::::::::' >> /data/etc/shadow
|
||||
fi
|
||||
|
||||
# remove shadow backups
|
||||
rm -f /data/etc/shadow+
|
||||
rm -f /data/etc/shadow-
|
||||
|
||||
# set root and admin passwords (admin is just an alias for root)
|
||||
|
||||
echo -en "$PASSWORD\n$PASSWORD\n" | passwd &>/dev/null # root
|
||||
echo -en "$PASSWORD\n$PASSWORD\n" | passwd admin &>/dev/null # admin
|
||||
|
||||
sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration
|
||||
sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration
|
||||
|
Loading…
x
Reference in New Issue
Block a user