diff --git a/ucloud-init.start b/ucloud-init.start index 98fa428..2de19a3 100755 --- a/ucloud-init.start +++ b/ucloud-init.start @@ -1,9 +1,22 @@ #!/bin/sh +# Functions + get_distro() { OS=$(cat /etc/*release | grep ID | head -1 | cut -c 4-) echo $OS } + + +# Main Code Starts here + +# Some common path variable declaration +ssh_authorized_keys_path='/root/.ssh/authorized_keys' +ssh_config_path='/etc/ssh/ssh_config' +sshd_config_path='/etc/ssh/sshd_config' + +# Check if rdnssd is installed, if not put ungleich DNS +# into /etc/resolv.conf and install rdnssd for the next time if ! $(which rdnssd); then echo "nameserver 2a0a:e5c0::3" >> /etc/resolv.conf echo "nameserver 2a0a:e5c0::4" >> /etc/resolv.conf @@ -11,16 +24,14 @@ if ! $(which rdnssd); then apk add ndisc6 fi -# Get IPv6 DNS +# Start rdnssd to get DNS rdnssd -u root -r /etc/resolv.conf -ssh_authorized_keys_path='/root/.ssh/authorized_keys' -ssh_config_path='/etc/ssh/ssh_config' -sshd_config_path='/etc/ssh/sshd_config' + # Initial Package Intallation -if [ [ $(get_distro) = "alpine" ]; then +if [[ $(get_distro) = "alpine" ]]; then apk update - apk add python3 openssh-server sfdisk util-linux jq + apk add openssh-server sfdisk util-linux jq touch $ssh_authorized_keys_path if ! grep -q "PasswordAuthentication no" $ssh_config_path; then