linux_ws2122/solutions/overlayfs.sh

38 lines
1.2 KiB
Bash
Raw Normal View History

2021-10-13 17:25:16 +00:00
#!/bin/bash
# 7a
mkdir --parent /root/workspace/overlayfs
cd /root/workspace/overlayfs
# 7b1
mkdir --parent ./lower_0/usr/bin
touch ./lower_0/usr/bin/mybin
# 7b2
mkdir --parent ./lower_1/etc/mybin
touch ./lower_1/etc/mybin/config.json
# 7b3
mkdir --parent ./lower_2/var/log/mybin
touch ./lower_2/var/log/mybin/info.log
# 7b4
mkdir --parent ./lower_3/usr/lib/systemd/system
touch ./lower_3/usr/lib/systemd/system/mybin.service
# 7b5
mkdir --parent ./lower_4/etc/mybin/conf.d/
touch ./lower_4/etc/mybin/conf.d/sqlite.config
# 7b6
mkdir --parent ./lower_5/etc/mybin/conf.d/
touch ./lower_4/etc/mybin/conf.d/postgresql.config
# 7c
mkdir --parent ./upper_application ./upper_application_plugins
mkdir --parent ./workdir_application ./workdir_application_plugins
mkdir --parent ./application ./application_plugins
mount -t overlay -o lowerdir=$(pwd)/lower_0:$(pwd)/lower_1:/$(pwd)/lower_2:/$(pwd)/lower_3,upperdir=$(pwd)/upper_application,workdir=$(pwd)/workdir_application overlayfs $(pwd)/application
mount -t overlay -o lowerdir=$(pwd)/lower_0:$(pwd)/lower_1:/$(pwd)/lower_2:/$(pwd)/lower_3:/$(pwd)/lower_4:/$(pwd)/lower_5,upperdir=$(pwd)/upper_application_plugins,workdir=$(pwd)/workdir_application_plugins overlayfs $(pwd)/application_plugins