On Tue, Oct 20, 2020 at 12:22:19PM +0800, Wu Fengguang wrote:
+# Install functions
Useless comment, please remove.
Ok i will delete it.
+install_packages() +{
- echo "install"
- yum repolist
- yum -y install --skip-broken $(</tmp/packages-to-install)
- yum clean all
+}
+# Setup functions
ditto
Ok.
+setup_rootfs() +{
- echo "setup"
- ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+}
+# Config password
ditto
Ok.
+setup_login() {
- [ -n "$ROOT_NEW_PASSWD" ] || return
- echo "Changing root password"
- passwd_md5=$(openssl passwd -1 "$ROOT_NEW_PASSWD")
- 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
ditto
Ok
+# Check password file
ditto
Ok
+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."
echo "$HOME/.config/compass-ci/rootfs-passwd"
exit 1
}
export ROOT_NEW_PASSWD=$(cat "$root_pwd_file")
+}
+# Pull docker image
ditto
Ok
+pull_docker_image() +{
- docker pull $image
- if [ $? = 0 ]; then
echo "finish downloading image"
- else
echo "[INFO] Pull docker image failed."
exit
- fi
+}
+# cp image package to host
ditto
Ok
Thanks, Chenglong
+cp_image()
cp_image => docker_cp_image
+{
- docker cp -a init_docker:/tmp/${image_name} $HOME/
- echo "result: $(ls $HOME/${image_name})"
+}
Thanks, Fengguang