On Wed, Dec 09, 2020 at 09:12:02AM +0800, Wang Chenglong wrote:
install software, set password and other actions in container.
Signed-off-by: Wang Chenglong 18509160991@163.com
container/docker-rootfs/setup-image | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 container/docker-rootfs/setup-image
diff --git a/container/docker-rootfs/setup-image b/container/docker-rootfs/setup-image new file mode 100755 index 0000000..0fa1eb6 --- /dev/null +++ b/container/docker-rootfs/setup-image @@ -0,0 +1,36 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+install_packages() +{
yum -y install --skip-broken $(</tmp/packages-to-install)
yum clean all
+}
+remove_file() +{
- rm -rf /.dockerenv
+}
+setup_login() +{
[ -n "$ROOT_PASSWD" ] || return
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_PASSWD")
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
will the system use $ROOTFS_DIR/ as the default /? if it allows to set the passwd use command?
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
why don't set the default value to yes? default permit login.
Thanks, Luan Shengde
+}
+pack_cgz() +{
echo "Packing package. Please wait."
find ./ ! -path "./tmp/${IMAGE_PACK}" | cpio -o -Hnewc | gzip -9 >./tmp/$IMAGE_PACK
chmod 644 /tmp/${IMAGE_PACK}
+}
+install_packages +remove_file +setup_login
+pack_cgz
2.23.0