On Sat, Oct 10, 2020 at 03:36:14PM +0800, Xiao Shenwei wrote:
+#config passwd +pre_config_rootfs() {
- [ -n "$ROOT_NEW_PASSWD" ] && {
echo "Changing root password"
passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
echo $passwd_md5
add a comment may be better
good idea.
sed -i -r "s/^root:[^:]*:(.*)/root:${passwd_md5//\//\\/}:\1/" "$ROOTFS_DIR/etc/shadow"
sed -i 's/[# ]PermitRootLogin.*/PermitRootLogin yes/' "$ROOTFS_DIR/etc/ssh/sshd_config"
- }
+}
+#pack cgz package +pack_cgz() +{
- echo "Packing package. Please wait."
- cd /
ditto
ok.
- find ./ ! -path "./${image_name}" ! -path "./root/modules/modules-5.8.0.1.cgz" |cpio -o -Hnewc |gzip -9 >/${image_name}
- chmod 644 /${image_name}
+}
+#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+DIR="$(dirname $(realpath $0))" +image="centos:7"
you can get the current path, then split it to get the name and version
Ok. good idea.
+name="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 1)" +version="$(echo "$image" | cut -d '/' -f 2 | cut -d ':' -f 2)" +image_name="${name}-${version}.cgz"
+#check passwd file
# check passwd file
+check_passwd_file() {
- root_pwd_file="$HOME/.config/compass-ci/rootfs.passwd"
export ROOT_NEW_PASSWD=
[ -f "$root_pwd_file" ] || {
echo "[INFO] Please set the password file."
format
Ok.
echo "$HOME/.config/compass-ci/rootfs.passwd"
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
+#pull_docker +pull_docker() +{
- docker pull $image || return
- echo "finsh down image"
finished down load image
Ok
+} @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+docker rm -f init_docker 2&> /dev/null
we have a function to del container, CCI_SRC/container/defconfig.sh
Ok. good idea
+. ./bin/lib
+check_passwd_file "$root_pwd_file"
+DIR=$(dirname $(realpath $0)) +cmd=(
- docker run
- --name init_docker
can add --rm ?
Ok. I will add.
Thanks, Chenglong
Thanks, Shenwei
- -v $DIR/bin/:/root/bin
- -v /srv/initrd/modules/:/root/modules
- -e ROOT_NEW_PASSWD=$ROOT_NEW_PASSWD
- -e image_name=$image_name
- $image
- /root/bin/creat
+)
+pull_docker
+${cmd[@]}
+docker cp -a init_docker:/${image_name} ./ +echo "build finished!!!"
-- 2.23.0