1#!/bin/bash 2# Copyright (C) 2020-2022 Intel Corporation. 3# SPDX-License-Identifier: BSD-3-Clause 4 5logger_prefix="(hmi-vm-rootfs) " 6source /root/.bashrc 7source logger.sh 8 9function umount_directory() { 10 target_dir=$1 11 umount -q ${target_dir} || true 12} 13 14function update_package_info() { 15 apt update -y 16 # Remove needrestart to disable interactive prompts in apt install 17 apt remove -y needrestart 18 apt install -y python3 python3-pip net-tools python3-matplotlib openssh-server \ 19 isc-dhcp-server linux-generic-hwe-$(lsb_release -sr) 20 pip3 install flask 'numpy>=1.18.5' pandas posix_ipc 21} 22 23function install_desktop() { 24 apt install ubuntu-gnome-desktop -y 25} 26 27function cleanup_packages() { 28 apt autoremove -y 29} 30 31function change_root_password() { 32 passwd root 33} 34 35function enable_root_login() { 36 sed -i -e '3 s/^/#/' /etc/pam.d/gdm-password 37 sed -i 's/\[daemon\]/& \n AllowRoot=true /' /etc/gdm3/custom.conf 38} 39 40function add_normal_user() { 41 useradd -s /bin/bash -d /home/acrn/ -m -G sudo acrn && \ 42 passwd acrn 43} 44 45function enable_services() { 46 services=(ssh.service isc-dhcp-server) 47 for service in ${services[*]} 48 do 49 systemctl enable ${service} 50 systemctl unmask ${service} 51 done 52} 53 54function config_ssh() { 55 56 sudo sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/g' \ 57 /etc/ssh/sshd_config 58 sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key 59 sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key 60} 61 62# Change current working directory to the root to avoid "target is busy" errors 63# on unmounting. 64cd / 65 66try_step "Unmounting /root" umount_directory /root 67try_step "Unmounting /home" umount_directory /home 68try_step "Updating package information" update_package_info 69try_step "Installing GNOME desktop" install_desktop 70try_step "Cleaning up packages" cleanup_packages 71try_step "Changing the password of the root user" change_root_password 72try_step "Enable root user login" enable_root_login 73try_step "Adding the normal user acrn" add_normal_user 74try_step "Configure the ssh service" config_ssh 75