-
Notifications
You must be signed in to change notification settings - Fork 12
/
password-reset-rhel.userdata
33 lines (25 loc) · 1.11 KB
/
password-reset-rhel.userdata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
WEB_SERVER="10.12.137.55:8181"
if [[ ! -d /var/lib/password-reset ]]
then
mkdir /var/lib/password-reset
fi
echo "#!/bin/bash"> /var/lib/password-reset/password-reset.sh
echo "curl -o /var/lib/password-reset/password-reset.py http://${WEB_SERVER}/password-reset.py">> /var/lib/password-reset/password-reset.sh
echo 'echo "INFO: Downloaded the latest /var/lib/password-reset/password-reset.py"'>> /var/lib/password-reset/password-reset.sh
echo "python /var/lib/password-reset/password-reset.py">> /var/lib/password-reset/password-reset.sh
chmod +x /var/lib/password-reset/password-reset.sh
echo "#!/bin/bash"> /usr/lib/systemd/scripts/password-reset
echo "/var/lib/password-reset/password-reset.sh">> /usr/lib/systemd/scripts/password-reset
chmod +x /usr/lib/systemd/scripts/password-reset
cat << EOF > /usr/lib/systemd/system/password-reset.service
[Unit]
Description=Reset root password if requested via cloud-init metadata
[Service]
Type=idle
ExecStart=/usr/lib/systemd/scripts/password-reset
[Install]
WantedBy=multi-user.target
EOF
systemctl enable password-reset.service
/var/lib/password-reset/password-reset.sh