fix Build-requires when image ISO is in SRPM
[ovirt-node-image.git] / livecd-setauth
blobeb8922fb3f6d0879ee452550f6c2f863d6f20a89
1 #!/bin/bash
3 # Script to interactively add root password and authorized_keys file
4 # to a livecd
5 # Copyright 2008 Red Hat, Inc.
6 # Written by Perry Myers <pmyers@redhat.com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; version 2 of the License.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 DEFAULT_AUTH=~/.ssh/authorized_keys
23 printf "Do you want to set a root password? [y/N]: "
24 read yesno
25 if [ "$yesno" = "y" -o "$yesno" = "Y" ]; then
26 chroot . passwd root
29 printf "Do you want to set an authorized_keys file? [y/N]: "
30 read yesno
31 if [ "$yesno" = "y" -o "$yesno" = "Y" ]; then
32 echo "Enter the location of the authorized_keys file [default: $DEFAULT_AUTH]: "
33 read -e authkeys
34 if [ -z "$authkeys" ]; then
35 authkeys=$DEFAULT_AUTH
38 authkeys=$(eval echo $authkeys)
39 if [ -f $authkeys ]; then
40 SSH=root/.ssh
41 AUTH=$SSH/authorized_keys
43 mkdir -p $SSH
44 chmod 755 $SSH
45 cp -v $authkeys $AUTH
46 chmod 644 $AUTH
47 else
48 echo "$authkeys not found, skipping"