File: passwordsetup.sh

package info (click to toggle)
sispmctl 4.12-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,964 kB
  • sloc: sh: 4,602; ansic: 1,629; makefile: 77; xml: 28
file content (34 lines) | stat: -rwxr-xr-x 704 bytes parent folder | download | duplicates (2)
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
34
#!/bin/bash

set -e

echo 'SiS PM Control - Password Setup'
echo
FILE=/etc/sispmctl/password
which base64 > /dev/null || (echo base64 is missing; false)
id | grep '^uid=0(' > /dev/null || \
(echo This scripts must be run as root; false)
echo -n 'User name: '
read UNAME
while true
do
  echo -n 'Password: '
  read -s PASSWD
  echo
  echo -n 'Repeat password: '
  read -s PASSWD2
  echo
  if [[ "x$PASSWD" == "x$PASSWD2" ]]; then
    break;
  fi
  echo
  echo The password inputs did not match.
done
SECRET=$(echo -n "$UNAME:$PASSWD" | base64)
mkdir -p /etc/sispmctl
rm -f $FILE
echo $SECRET > $FILE
chmod 400 $FILE
chown sispmctl $FILE
echo
echo To enable the new password restart the sispmctl services.