do not quit when ssh key file not exists

Change-Id: I1c0eab5d52656b4560527c89eaeb56696090ed38
This commit is contained in:
xiaodongwang 2015-04-03 18:55:37 -07:00
parent 587250bfae
commit d10c96c3f8
8 changed files with 97 additions and 58 deletions

View File

@ -56,6 +56,9 @@ d-i mirror/country string manual
d-i mirror/http/hostname string $http_server
d-i mirror/http/directory string $install_source_directory
d-i mirror/http/proxy string
d-i mirror/http/mirror select $http_server
d-i mirror/protocol select http
d-i mirror/udeb/components multiselect main, restricted
#set $os_v = $getVar('os_version','')
#if $os_v and $os_v.lower()[0] > 'p'

View File

@ -29,5 +29,5 @@ for remove_partition in \${remove_partitions}; do
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
continue
fi
parted \${partition_disk} rm \${partition_number}
parted \${partition_disk} --script -- rm \${partition_number}
done

View File

@ -1,24 +1,34 @@
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
#if $ssh_keys != ""
mkdir -p /root/.ssh
chmod 700 -R /root/.ssh
#set user_name = $getVar("username", "root")
#if $user_name == "root"
#set home = "/root"
#else
#set home = "/home/%s" % $user_name
#end if
mkdir -p $home/.ssh
chmod 700 -R $home/.ssh
#set $firstline = True
#for $ssh_key in $ssh_keys.split(',')
#if not $ssh_key
#continue
#end if
#set f = $open($ssh_key)
#if $firstline
cat << EOL > /root/.ssh/authorized_keys
#echo $f.read()
#try
#set f = $open($ssh_key)
#if $firstline
cat << EOL > $home/.ssh/authorized_keys
#echo $f.read()
EOL
#else
cat << EOL >> /root/.ssh/authorized_keys
#echo $f.read()
#else
cat << EOL >> $home/.ssh/authorized_keys
#echo $f.read()
EOL
#end if
#silent $f.close()
#set $firstline = False
#end if
#set $firstline = False
#silent $f.close()
#except
# failed to read from $ssh_key
#end try
#end for
chmod 600 /root/.ssh/authorized_keys
chmod 600 $home/.ssh/authorized_keys
#end if

View File

@ -1,6 +1,8 @@
# Uncomment this if you don't want to use a network mirror
d-i apt-setup/use_mirror boolean false
d-i apt-setup/services-select multiselect
d-i apt-setup/security_host string $http_server
d-i apt-setup/security_path string $install_source_directory
# Additional repositories, local[0-9] available
#set $cur=0
#set $repo_data = $getVar("repo_data",[])

View File

@ -19,3 +19,5 @@ d-i partman/choose_partition select Finish partitioning and write changes to dis
d-i mdadm/boot_degraded boolean true
d-i partman-auto-lvm/no_boot boolean true
d-i partman-basicfilesystems/no_mount_point false
d-i partman/filter_mounted boolean false
d-i partman/unmount_active boolean false

View File

@ -1,25 +1,36 @@
sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
#if $ssh_keys != ""
mkdir -p /root/.ssh
chmod 700 -R /root/.ssh
#set user_name = $getVar("username", "root")
#if $user_name == "root"
#set home = "/root"
#else
#set home = "/home/%s" % $user_name
#end if
mkdir -p $home/.ssh
chmod 700 -R $home/.ssh
#set $firstline = True
#for $ssh_key in $ssh_keys.split(',')
#if not $ssh_key
#continue
#end if
#set $f = $open($ssh_key)
#if firstline
cat << EOF > /root/.ssh/authorized_keys
#echo $f.read()
#try
#set $f = $open($ssh_key)
#if firstline
cat << EOF > $home/.ssh/authorized_keys
#echo $f.read()
EOF
#else
cat << EOF >> /root/.ssh/authorized_keys
#echo $f.read()
#else
cat << EOF >> $home/.ssh/authorized_keys
#echo $f.read()
EOF
#end if
#set $firstline = False
#silent $f.close()
#end if
#set $firstline = False
#silent $f.close()
#except
# failed to read from $ssh_key
#end try
#end for
chmod 600 /root/.ssh/authorized_keys
chmod 600 $home/.ssh/authorized_keys
#end if

View File

@ -1,33 +1,43 @@
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
#if $ssh_keys != ""
#set user_name = $getVar("username", "root")
#if $user_name == "root"
#set home = "/root"
#else
#set home = "/home/%s" % $user_name
#end if
<file>
<file_path>/root/.ssh/authorized_keys</file_path>
<file_owner>root.root</file_owner>
<file_path>$home/.ssh/authorized_keys</file_path>
<file_owner>${user_name}.${user_name}</file_owner>
<file_permissions>600</file_permissions>
<file_script>
<interpreter>shell</interpreter>
<source>
<![CDATA[
\#!/bin/bash
mkdir -p /root/.ssh
chmod 700 -R /root/.ssh
mkdir -p $home/.ssh
chmod 700 -R $home/.ssh
#set $firstline = True
#for $ssh_key in $ssh_keys.split(',')
#if not $ssh_key
#continue
#end if
#set f = $open($ssh_key)
#if $firstline
cat << EOL > /root/.ssh/authorized_keys
#echo $f.read()
#try
#set f = $open($ssh_key)
#if $firstline
cat << EOL > $home/.ssh/authorized_keys
#echo $f.read()
EOL
#else
cat << EOL >> /root/.ssh/authorized_keys
#echo $f.read()
#else
cat << EOL >> $home/.ssh/authorized_keys
#echo $f.read()
EOL
#end if
#silent $f.close()
#set $firstline = False
#end if
#set $firstline = False
#silent $f.close()
#except
# failed to read from $ssh_key
#end try
#end for
]]>
</source>

View File

@ -488,22 +488,23 @@ for disk in \${disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk=\\${used_disk_\${disk_name}}"
if [[ -z "\$used_disk" ]]; then
partition_numer=\$(lsblk -n -o MAJ:MIN,TYPE \$disk | grep part | awk '{print \$1}' | cut -d: -f2)
parted \$disk --script -- rm \${partition_numer}
fi
done
#end if
#if $getVar('keep_old_partitions', '0') == "0"
for disk in \${disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk=\\${used_disk_\${disk_name}}"
if [[ -z "\$used_disk" ]]; then
partition_numers=\$(parted \$disk --script -- p | awk '/^ / {print \$1}')
echo "remove partition numbers \${partition_numers} on disk \$disk" >> /tmp/log
for partition_numer in \${partition_numers}; do
parted \$disk --script -- rm \${partition_numer}
done
echo '<drive>' >> /tmp/profile/partition.xml
echo " <device>\$disk</device>" >> /tmp/profile/partition.xml
echo ' <initialize config:type="boolean">true</initialize>' >> /tmp/profile/partition.xml
echo ' <use>all</use>' >> /tmp/profile/partition.xml
echo ' <disklabel>gpt</disklabel>' >> /tmp/profile/partition.xml
echo ' <partitions config:type="list">' >> /tmp/profile/partition.xml
echo "add partition /reserved_\${disk_name} into partitions" >> /tmp/log
echo ' <partition>' >> /tmp/profile/partition.xml
echo " <filesystem config:type=\"symbol\">\${partition_fstype}</filesystem>" >> /tmp/profile/partition.xml
echo ' <format config:type="boolean">true</format>' >> /tmp/profile/partition.xml
echo " <mount>/reserved_\${disk_name}</mount>" >> /tmp/profile/partition.xml
echo ' <mountby config:type="symbol">label</mountby>' >> /tmp/profile/partition.xml
echo " <label>reserved_\${disk_name}</label>" >> /tmp/profile/partition.xml
echo " <size>max</size>" >> /tmp/profile/partition.xml
echo ' </partition>' >> /tmp/profile/partition.xml
echo ' </partitions>' >> /tmp/profile/partition.xml
echo '</drive>' >> /tmp/profile/partition.xml
fi
done
#end if