do not quit when ssh key file not exists
Change-Id: I1c0eab5d52656b4560527c89eaeb56696090ed38
This commit is contained in:
parent
587250bfae
commit
d10c96c3f8
@ -56,6 +56,9 @@ d-i mirror/country string manual
|
|||||||
d-i mirror/http/hostname string $http_server
|
d-i mirror/http/hostname string $http_server
|
||||||
d-i mirror/http/directory string $install_source_directory
|
d-i mirror/http/directory string $install_source_directory
|
||||||
d-i mirror/http/proxy string
|
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','')
|
#set $os_v = $getVar('os_version','')
|
||||||
#if $os_v and $os_v.lower()[0] > 'p'
|
#if $os_v and $os_v.lower()[0] > 'p'
|
||||||
|
@ -29,5 +29,5 @@ for remove_partition in \${remove_partitions}; do
|
|||||||
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
|
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
parted \${partition_disk} rm \${partition_number}
|
parted \${partition_disk} --script -- rm \${partition_number}
|
||||||
done
|
done
|
||||||
|
@ -1,24 +1,34 @@
|
|||||||
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
|
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
|
||||||
#if $ssh_keys != ""
|
#if $ssh_keys != ""
|
||||||
mkdir -p /root/.ssh
|
#set user_name = $getVar("username", "root")
|
||||||
chmod 700 -R /root/.ssh
|
#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
|
#set $firstline = True
|
||||||
#for $ssh_key in $ssh_keys.split(',')
|
#for $ssh_key in $ssh_keys.split(',')
|
||||||
#if not $ssh_key
|
#if not $ssh_key
|
||||||
#continue
|
#continue
|
||||||
#end if
|
#end if
|
||||||
#set f = $open($ssh_key)
|
#try
|
||||||
#if $firstline
|
#set f = $open($ssh_key)
|
||||||
cat << EOL > /root/.ssh/authorized_keys
|
#if $firstline
|
||||||
#echo $f.read()
|
cat << EOL > $home/.ssh/authorized_keys
|
||||||
|
#echo $f.read()
|
||||||
EOL
|
EOL
|
||||||
#else
|
#else
|
||||||
cat << EOL >> /root/.ssh/authorized_keys
|
cat << EOL >> $home/.ssh/authorized_keys
|
||||||
#echo $f.read()
|
#echo $f.read()
|
||||||
EOL
|
EOL
|
||||||
#end if
|
#end if
|
||||||
#silent $f.close()
|
#set $firstline = False
|
||||||
#set $firstline = False
|
#silent $f.close()
|
||||||
|
#except
|
||||||
|
# failed to read from $ssh_key
|
||||||
|
#end try
|
||||||
#end for
|
#end for
|
||||||
chmod 600 /root/.ssh/authorized_keys
|
chmod 600 $home/.ssh/authorized_keys
|
||||||
#end if
|
#end if
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# Uncomment this if you don't want to use a network mirror
|
# Uncomment this if you don't want to use a network mirror
|
||||||
d-i apt-setup/use_mirror boolean false
|
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
|
# Additional repositories, local[0-9] available
|
||||||
#set $cur=0
|
#set $cur=0
|
||||||
#set $repo_data = $getVar("repo_data",[])
|
#set $repo_data = $getVar("repo_data",[])
|
||||||
|
@ -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 mdadm/boot_degraded boolean true
|
||||||
d-i partman-auto-lvm/no_boot boolean true
|
d-i partman-auto-lvm/no_boot boolean true
|
||||||
d-i partman-basicfilesystems/no_mount_point false
|
d-i partman-basicfilesystems/no_mount_point false
|
||||||
|
d-i partman/filter_mounted boolean false
|
||||||
|
d-i partman/unmount_active boolean false
|
||||||
|
@ -1,25 +1,36 @@
|
|||||||
sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
||||||
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
|
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
|
||||||
#if $ssh_keys != ""
|
#if $ssh_keys != ""
|
||||||
mkdir -p /root/.ssh
|
#set user_name = $getVar("username", "root")
|
||||||
chmod 700 -R /root/.ssh
|
#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
|
#set $firstline = True
|
||||||
#for $ssh_key in $ssh_keys.split(',')
|
#for $ssh_key in $ssh_keys.split(',')
|
||||||
#if not $ssh_key
|
#if not $ssh_key
|
||||||
#continue
|
#continue
|
||||||
#end if
|
#end if
|
||||||
#set $f = $open($ssh_key)
|
#try
|
||||||
#if firstline
|
#set $f = $open($ssh_key)
|
||||||
cat << EOF > /root/.ssh/authorized_keys
|
#if firstline
|
||||||
#echo $f.read()
|
cat << EOF > $home/.ssh/authorized_keys
|
||||||
|
#echo $f.read()
|
||||||
EOF
|
EOF
|
||||||
#else
|
#else
|
||||||
cat << EOF >> /root/.ssh/authorized_keys
|
cat << EOF >> $home/.ssh/authorized_keys
|
||||||
#echo $f.read()
|
#echo $f.read()
|
||||||
EOF
|
EOF
|
||||||
#end if
|
#end if
|
||||||
#set $firstline = False
|
#set $firstline = False
|
||||||
#silent $f.close()
|
#silent $f.close()
|
||||||
|
#except
|
||||||
|
# failed to read from $ssh_key
|
||||||
|
#end try
|
||||||
#end for
|
#end for
|
||||||
chmod 600 /root/.ssh/authorized_keys
|
chmod 600 $home/.ssh/authorized_keys
|
||||||
#end if
|
#end if
|
||||||
|
@ -1,33 +1,43 @@
|
|||||||
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
|
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
|
||||||
#if $ssh_keys != ""
|
#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>
|
||||||
<file_path>/root/.ssh/authorized_keys</file_path>
|
<file_path>$home/.ssh/authorized_keys</file_path>
|
||||||
<file_owner>root.root</file_owner>
|
<file_owner>${user_name}.${user_name}</file_owner>
|
||||||
<file_permissions>600</file_permissions>
|
<file_permissions>600</file_permissions>
|
||||||
<file_script>
|
<file_script>
|
||||||
<interpreter>shell</interpreter>
|
<interpreter>shell</interpreter>
|
||||||
<source>
|
<source>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
\#!/bin/bash
|
\#!/bin/bash
|
||||||
mkdir -p /root/.ssh
|
mkdir -p $home/.ssh
|
||||||
chmod 700 -R /root/.ssh
|
chmod 700 -R $home/.ssh
|
||||||
#set $firstline = True
|
#set $firstline = True
|
||||||
#for $ssh_key in $ssh_keys.split(',')
|
#for $ssh_key in $ssh_keys.split(',')
|
||||||
#if not $ssh_key
|
#if not $ssh_key
|
||||||
#continue
|
#continue
|
||||||
#end if
|
#end if
|
||||||
#set f = $open($ssh_key)
|
#try
|
||||||
#if $firstline
|
#set f = $open($ssh_key)
|
||||||
cat << EOL > /root/.ssh/authorized_keys
|
#if $firstline
|
||||||
#echo $f.read()
|
cat << EOL > $home/.ssh/authorized_keys
|
||||||
|
#echo $f.read()
|
||||||
EOL
|
EOL
|
||||||
#else
|
#else
|
||||||
cat << EOL >> /root/.ssh/authorized_keys
|
cat << EOL >> $home/.ssh/authorized_keys
|
||||||
#echo $f.read()
|
#echo $f.read()
|
||||||
EOL
|
EOL
|
||||||
#end if
|
#end if
|
||||||
#silent $f.close()
|
#set $firstline = False
|
||||||
#set $firstline = False
|
#silent $f.close()
|
||||||
|
#except
|
||||||
|
# failed to read from $ssh_key
|
||||||
|
#end try
|
||||||
#end for
|
#end for
|
||||||
]]>
|
]]>
|
||||||
</source>
|
</source>
|
||||||
|
@ -488,22 +488,23 @@ for disk in \${disks[@]}; do
|
|||||||
disk_name=\$(basename \$disk)
|
disk_name=\$(basename \$disk)
|
||||||
eval "used_disk=\\${used_disk_\${disk_name}}"
|
eval "used_disk=\\${used_disk_\${disk_name}}"
|
||||||
if [[ -z "\$used_disk" ]]; then
|
if [[ -z "\$used_disk" ]]; then
|
||||||
partition_numer=\$(lsblk -n -o MAJ:MIN,TYPE \$disk | grep part | awk '{print \$1}' | cut -d: -f2)
|
echo '<drive>' >> /tmp/profile/partition.xml
|
||||||
parted \$disk --script -- rm \${partition_numer}
|
echo " <device>\$disk</device>" >> /tmp/profile/partition.xml
|
||||||
fi
|
echo ' <initialize config:type="boolean">true</initialize>' >> /tmp/profile/partition.xml
|
||||||
done
|
echo ' <use>all</use>' >> /tmp/profile/partition.xml
|
||||||
#end if
|
echo ' <disklabel>gpt</disklabel>' >> /tmp/profile/partition.xml
|
||||||
|
echo ' <partitions config:type="list">' >> /tmp/profile/partition.xml
|
||||||
#if $getVar('keep_old_partitions', '0') == "0"
|
echo "add partition /reserved_\${disk_name} into partitions" >> /tmp/log
|
||||||
for disk in \${disks[@]}; do
|
echo ' <partition>' >> /tmp/profile/partition.xml
|
||||||
disk_name=\$(basename \$disk)
|
echo " <filesystem config:type=\"symbol\">\${partition_fstype}</filesystem>" >> /tmp/profile/partition.xml
|
||||||
eval "used_disk=\\${used_disk_\${disk_name}}"
|
echo ' <format config:type="boolean">true</format>' >> /tmp/profile/partition.xml
|
||||||
if [[ -z "\$used_disk" ]]; then
|
echo " <mount>/reserved_\${disk_name}</mount>" >> /tmp/profile/partition.xml
|
||||||
partition_numers=\$(parted \$disk --script -- p | awk '/^ / {print \$1}')
|
echo ' <mountby config:type="symbol">label</mountby>' >> /tmp/profile/partition.xml
|
||||||
echo "remove partition numbers \${partition_numers} on disk \$disk" >> /tmp/log
|
echo " <label>reserved_\${disk_name}</label>" >> /tmp/profile/partition.xml
|
||||||
for partition_numer in \${partition_numers}; do
|
echo " <size>max</size>" >> /tmp/profile/partition.xml
|
||||||
parted \$disk --script -- rm \${partition_numer}
|
echo ' </partition>' >> /tmp/profile/partition.xml
|
||||||
done
|
echo ' </partitions>' >> /tmp/profile/partition.xml
|
||||||
|
echo '</drive>' >> /tmp/profile/partition.xml
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
#end if
|
#end if
|
||||||
|
Loading…
x
Reference in New Issue
Block a user