SampleApplication: Update the image create scripts

1. Delete the generated images if the create scripts failed.
2. Enable root user login on GUI.
3. Enable systemd service in case there are many error logs.

Tracked-On: #7820
Signed-off-by: Liu Long <long.liu@linux.intel.com>
This commit is contained in:
Liu Long 2022-08-17 11:17:13 +08:00 committed by acrnsi-robot
parent 7f3174f740
commit e6de2e5798
3 changed files with 29 additions and 13 deletions

View File

@ -110,7 +110,6 @@ function dump_proxy() {
sudo mv ${temp_file} proxy.conf sudo mv ${temp_file} proxy.conf
echo "$(env | grep -Ei _proxy | sed -e 's/^/export /')" > bashrc echo "$(env | grep -Ei _proxy | sed -e 's/^/export /')" > bashrc
} }
function resizing_guest_root() { function resizing_guest_root() {
@ -204,9 +203,11 @@ function cleanup() {
sudo umount ${mount_point} sudo umount ${mount_point}
sudo rmdir ${mount_point} sudo rmdir ${mount_point}
echo ${mount_point}
sudo kpartx -vd /dev/${loop_dev} sudo kpartx -vd /dev/${loop_dev}
sudo losetup -vd /dev/${loop_dev} sudo losetup -vd /dev/${loop_dev}
if [[ ${has_error} != 0 ]]; then
sudo rm ${target_image}
fi
true true
} }
@ -250,3 +251,4 @@ fi
do_step "Cleaning up" cleanup ${mount_point} ${loop_dev} do_step "Cleaning up" cleanup ${mount_point} ${loop_dev}
print_info "VM image created at ${target_image}." print_info "VM image created at ${target_image}."

View File

@ -15,24 +15,40 @@ function update_package_info() {
apt update -y && apt install python3 python3-pip \ apt update -y && apt install python3 python3-pip \
net-tools python3-matplotlib \ net-tools python3-matplotlib \
linux-modules-extra-$(uname -r) \ linux-modules-extra-$(uname -r) \
openssh-server -y openssh-server \
isc-dhcp-server -y
pip3 install flask 'numpy==1.18.5' pandas posix_ipc pip3 install flask 'numpy==1.18.5' pandas posix_ipc
} }
function install_desktop() { function install_desktop() {
apt install ubuntu-gnome-desktop apt install ubuntu-gnome-desktop -y
} }
function change_root_password() { function change_root_password() {
passwd root passwd root
} }
function enable_root_login() {
sed -i -e '3 s/^/#/' /etc/pam.d/gdm-password
sed -i 's/\[daemon\]/& \n AllowRoot=true /' /etc/gdm3/custom.conf
}
function add_normal_user() { function add_normal_user() {
useradd -s /bin/bash -d /home/acrn/ -m -G sudo acrn && \ useradd -s /bin/bash -d /home/acrn/ -m -G sudo acrn && \
passwd acrn passwd acrn
} }
function enable_services() {
services=(ssh.service isc-dhcp-server)
sudo ssh-keygen -A
for service in ${services[*]}
do
systemctl enable ${service}
systemctl unmask ${service}
done
}
# Change current working directory to the root to avoid "target is busy" errors # Change current working directory to the root to avoid "target is busy" errors
# on unmounting. # on unmounting.
cd / cd /
@ -42,4 +58,5 @@ try_step "Unmounting /home" umount_directory /home
try_step "Updating package information" update_package_info try_step "Updating package information" update_package_info
try_step "Installing GNOME desktop" install_desktop try_step "Installing GNOME desktop" install_desktop
try_step "Changing the password of the root user" change_root_password try_step "Changing the password of the root user" change_root_password
try_step "Enable root user login" enable_root_login
try_step "Adding the normal user acrn" add_normal_user try_step "Adding the normal user acrn" add_normal_user

View File

@ -17,11 +17,11 @@ function disable_os_prober() {
} }
function update_package_info() { function update_package_info() {
apt update apt update -y
} }
function install_tools() { function install_tools() {
apt install rt-tests apt install rt-tests -y
} }
function update_kernel_cmdline() { function update_kernel_cmdline() {
@ -35,7 +35,7 @@ function install_rt_kernel() {
search_dir=$1 search_dir=$1
for file in $(ls -r ${search_dir}/*acrn-kernel-*.deb) for file in $(ls -r ${search_dir}/*acrn-kernel-*.deb)
do do
sudo apt install ${file} sudo apt install ${file} -y
done done
} }
@ -45,15 +45,12 @@ function change_root_password() {
function disable_services() { function disable_services() {
services=(systemd-timesyncd.service \ services=(systemd-timesyncd.service \
systemd-journald.service \
systemd-journal-flush.service \ systemd-journal-flush.service \
serial-getty@ttyS2.service \
apt-daily.service \ apt-daily.service \
apt-daily-upgrade.service \ apt-daily-upgrade.service \
snapd.autoimport.service \ snapd.autoimport.service \
snapd.seeded.service \ snapd.seeded.service)
snapd.service \
snapd.socket)
for service in ${services[*]} for service in ${services[*]}
do do
systemctl disable ${service} systemctl disable ${service}
@ -64,7 +61,7 @@ function disable_services() {
systemctl disable ${timer} systemctl disable ${timer}
done done
apt-get remove unattended-upgrades apt-get remove unattended-upgrades -y
} }
# Change current working directory to the root to avoid "target is busy" errors # Change current working directory to the root to avoid "target is busy" errors