forked from vvaldez/openstack-password-reset
-
Notifications
You must be signed in to change notification settings - Fork 1
/
password-reset-rhel.userdata
31 lines (24 loc) · 1.09 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
#!/bin/bash
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://10.12.137.55:8181/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