summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiwoong Ha <kw1981.ha@samsung.com>2022-10-25 19:35:04 +0900
committerKiwoong Ha <kw1981.ha@samsung.com>2022-10-26 09:57:49 +0900
commitb1642790d76d3733b23ccfc5720951fc72118fc7 (patch)
tree026cef000cef9cb7368feb6cd14ec8d1fdc159d6
parent28b7f2609db66a6b8fd5064af6d50ded6b3572c5 (diff)
downloaddocker-adaptor-accepted/tizen_unified.tar.gz
docker-adaptor-accepted/tizen_unified.tar.bz2
docker-adaptor-accepted/tizen_unified.zip
container_tool.sh will support below functionalities. 1. prepare environment for running container 2. run (create/start) container 3. start container 4. stop container 5. erase container Change-Id: I6eaa7a3b950d04741f4b389d1e8488c579d8b427 Signed-off-by: Kiwoong Ha <kw1981.ha@samsung.com>
-rw-r--r--README.md33
-rwxr-xr-xscripts/container_tool.sh255
2 files changed, 280 insertions, 8 deletions
diff --git a/README.md b/README.md
index 859937e..ab2e36b 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,37 @@
# docker-adaptor
-docker configurations and tizen-headed images for running tizen headed container
+docker configurations for running tizen headed container
Packages
* docker-adaptor-tizen-headed-{version}.{arch}.rpm
- - Tizen-headed container images and configurations with using tizen-headed images in download.tizen.org
+ - Tizen-headed container configurations
-Install
+How to use scrips/container_tool.sh
- * Requires
- - More than 4.5GB storage space is needed for rootfs, system-data, user, hal images
+ * Prepare environment for running container
+ - ./scripts/container_tool.sh prepare
+ - Install docker-engine, docker-launcher, hal-backend-docker-config, and mount user partiton for container images
+
+ * Run container (create/start container)
+ - ./scripts/container_tool.sh run
+ - Install docker-adaptor, tizen-headed images
+ - Build docker image and create/start tizen-headed container
+
+ * Stop container
+ - ./scripts/container_tool.sh stop
+
+ * Start container
+ - ./scripts/container_tool.sh start
+ * Erase container
+ - ./scripts/container_tool.sh erase
+ - Uninstall docker-adaptor, tizen-headed images
-When download images/packages scripts failed
- * Proxy setting
- - Add http_proxy={address}:{port} in scripts/set_env.sh
+Caution
+
+ * Requires
+ - More than 4.5GB storage space is needed for rootfs, system-data, user, hal images
+
diff --git a/scripts/container_tool.sh b/scripts/container_tool.sh
new file mode 100755
index 0000000..2d0b9ed
--- /dev/null
+++ b/scripts/container_tool.sh
@@ -0,0 +1,255 @@
+CUR_DIR=$(pwd)
+SCRIPT_DIR=$(dirname $0)
+CMD=$1
+CONTAINER=tizen-headed
+ARCH=aarch64
+
+CONTAINER_PATH=$SCRIPT_DIR/../container
+TARGET_CONTAINER_PATH=/opt/data/container
+
+TEMP_PATH=$SCRIPT_DIR/../temp
+TARGET_TEMP_PATH=/home/owner
+TARGET_HAL_PATH=/hal
+TARGET_HAL_LIB_PATH=$TARGET_HAL_PATH/lib64
+TARGET_LIB_PATH=/lib64
+
+
+install_package_on_headless()
+{
+ CONTAINER=$1
+ ARCH=$2
+ package_name=$3
+ target_name=$4
+
+ echo ""
+ echo "Download package - $package_name"
+ mkdir -p $TEMP_PATH
+ if [ -z $target_name ]; then
+ $SCRIPT_DIR/download_packages.sh $TEMP_PATH $ARCH $CONTAINER $package_name
+ else
+ $SCRIPT_DIR/download_packages.sh $TEMP_PATH $ARCH $CONTAINER $package_name-$target_name
+ fi
+
+ echo "Install package on headless - $package_name"
+ sdb push $TEMP_PATH/$package_name*.rpm $TARGET_TEMP_PATH
+ sdb shell rpm -Uvh $TARGET_TEMP_PATH/$package_name*.rpm
+ sdb shell rm -f $TARGET_TEMP_PATH/$package_name*.rpm
+ rm -rf $TEMP_PATH
+
+}
+
+uninstall_package_on_headless()
+{
+ CONTAINER=$1
+ ARCH=$2
+ package_name=$3
+ target_name=$4
+
+ echo ""
+ echo "Uninstall package on headless - $package_name"
+ if [ -z $target_name]; then
+ sdb shell rpm -e $package_name
+ else
+ sdb shell rpm -e $package_name-$target_name
+ fi
+}
+
+mount_user_partition_on_headless()
+{
+ echo""
+ echo "Mount user partition on headless"
+ sdb push $SCRIPT_DIR/setup-container-part-mnt.sh $TARGET_TEMP_PATH
+ sdb shell $TARGET_TEMP_PATH/setup-container-part-mnt.sh
+ sdb shell rm $TARGET_TEMP_PATH/setup-container-part-mnt.sh
+}
+
+reboot_target()
+{
+ echo ""
+ echo "Reboot target"
+ sdb shell reboot
+}
+
+download_images()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Download $CONTAINER images"
+ mkdir -p $CONTAINER_PATH/$CONTAINER/images
+ $SCRIPT_DIR/download_image.sh $CONTAINER_PATH $CONTAINER rootfs.img system-data.img user.img ramdisk.img
+ mv $CONTAINER_PATH/$CONTAINER/*.img $CONTAINER_PATH/$CONTAINER/images/
+}
+
+download_packages()
+{
+ CONTAINER=$1
+ ARCH=$2
+ echo ""
+ echo "Download system-plugin-feature-container-adaptor package"
+ mkdir -p $CONTAINER_PATH/$CONTAINER/init/plugin
+ $SCRIPT_DIR/download_packages.sh $CONTAINER_PATH/$CONTAINER/init/plugin $ARCH $CONTAINER system-plugin-feature-container-adaptor
+}
+
+make_tizen_init()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Make tizen-init.tar"
+ mkdir -p $CONTAINER_PATH/$CONTAINER/init/ramdisk
+ sudo mount -t ext4 $CONTAINER_PATH/$CONTAINER/images/ramdisk.img $CONTAINER_PATH/$CONTAINER/init/ramdisk
+ sudo tar cf $CONTAINER_PATH/$CONTAINER/tizen-init.tar -C $CONTAINER_PATH/$CONTAINER/init .
+ sudo umount $CONTAINER_PATH/$CONTAINER/init/ramdisk
+ rm -rf $CONTAINER_PATH/$CONTAINER/init/ramdisk
+ rm -rf $CONTAINER_PATH/$CONTAINER/images/ramdisk.img
+}
+
+root_on()
+{
+ sdb root on
+}
+
+root_off()
+{
+ sdb root off
+}
+
+remount_partition()
+{
+ path=$1
+ perm=$2
+ echo ""
+ echo "Remount $path for $perm permission"
+ sdb shell mount -o $perm,remount $path
+}
+
+copy_hal_for_container()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Copy headless hal for headed container"
+ sdb shell cp -af $TARGET_HAL_PATH $TARGET_CONTAINER_PATH/$CONTAINER/
+}
+
+push_images()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Push $CONTAINER images"
+ sdb push $CONTAINER_PATH/$CONTAINER/images $TARGET_CONTAINER_PATH/$CONTAINER/images
+}
+
+push_tizen_init()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Push tizen-init.tar"
+ sdb push $CONTAINER_PATH/$CONTAINER/tizen-init.tar $TARGET_CONTAINER_PATH/$CONTAINER/
+}
+
+update_tbm()
+{
+ TBM=$1
+ echo ""
+ echo "Update tbm - $TBM"
+ sdb shell rm $TARGET_HAL_LIB_PATH/libhal-backend-tbm.so
+ sdb shell ln -s libhal-backend-tbm-$TBM.so $TARGET_HAL_LIB_PATH/libhal-backend-tbm.so
+ sdb shell chsmack $TARGET_HAL_LIB_PATH/libhal-backend-tbm.so -a "_"
+}
+
+restart_display_manager()
+{
+ echo ""
+ echo "Restart display-manager"
+ sdb shell /sbin/ldconfig
+ sdb shell systemctl restart display-manager
+}
+
+start_container()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Start $CONTAINER container"
+ exist=$(sdb shell find $TARGET_CONTAINER_PATH/$CONTAINER -name config-$CONTAINER.json)
+ if [ ! -z $exist ]; then
+ sdb shell mv $TARGET_CONTAINER_PATH/$CONTAINER/config-$CONTAINER.json $TARGET_CONTAINER_PATH/list/
+ fi
+}
+
+stop_container()
+{
+ CONTAINER=$1
+ echo ""
+ echo "Stop $CONTAINER container"
+ exist=$(sdb shell find $TARGET_CONTAINER_PATH/list -name config-$CONTAINER.json)
+ if [ ! -z $exist ]; then
+ sdb shell mv $TARGET_CONTAINER_PATH/list/config-$CONTAINER.json $TARGET_CONTAINER_PATH/$CONTAINER/
+ fi
+}
+
+
+root_on
+case $CMD in
+ prepare)
+ remount_partition / rw
+ remount_partition /hal rw
+
+ install_package_on_headless $CONTAINER $ARCH docker-engine
+ install_package_on_headless $CONTAINER $ARCH jsoncpp
+ sdb shell chsmack $TARGET_LIB_PATH/libjsoncpp.so* -a "_"
+ install_package_on_headless $CONTAINER $ARCH docker-launcher
+ install_package_on_headless $CONTAINER $ARCH hal-backend-docker-config rpi4
+
+ remount_partition /hal ro
+
+ mount_user_partition_on_headless
+ remount_partition / ro
+
+ reboot_target
+ ;;
+ run)
+ remount_partition / rw
+ remount_partition /hal rw
+ install_package_on_headless $CONTAINER $ARCH docker-adaptor-$CONTAINER
+ download_images $CONTAINER
+ download_packages $CONTAINER $ARCH
+ copy_hal_for_container $CONTAINER
+ install_package_on_headless $CONTAINER $ARCH hal-backend-tbm-shm
+ update_tbm shm
+ restart_display_manager
+ remount_partition /hal ro
+ remount_partition / ro
+ make_tizen_init $CONTAINER
+ push_images $CONTAINER
+ push_tizen_init $CONTAINER
+ start_container $CONTAINER
+ root_off
+ ;;
+ stop)
+ stop_container $CONTAINER
+ root_off
+ ;;
+ start)
+ start_container $CONTAINER
+ root_off
+ ;;
+ erase)
+ stop_container $CONTAINER
+ remount_partition / rw
+ remount_partition /hal rw
+ uninstall_package_on_headless $CONTAINER $ARCH docker-adaptor-$CONTAINER
+ uninstall_package_on_headless $CONTAINER $ARCH hal-backend-tbm-shm
+ update_tbm vc4
+ restart_display_manager
+ remount_partition /hal ro
+ remount_partition / ro
+ root_off
+ ;;
+ *)
+ echo "** Help **"
+ echo "- $0 prepare : Prepare environment for running container (need to reboot target)"
+ echo "- $0 run : Install configurations and images for container, and then run container"
+ echo "- $0 stop : Stop container"
+ echo "- $0 start : Start container"
+ echo "- $0 erase : Stop container, and then uninstall configurations and images for container"
+ ;;
+esac