File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
src/backend/shell_scripts Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ name=$2
55resource=$3
66exp_port=$4
77max_mem=$5
8- enable_voume =$6
8+ enable_volume =$6
99
1010available_ports=()
1111STORAGE_ROOT=" /mnt/storage"
1212PROJECT_STORAGE=" $STORAGE_ROOT /$name "
13+ PROJECT_IMG=" $STORAGE_ROOT /$name .img"
14+ SIZE_MB=100
1315for (( port= PORT_MIN; port<= PORT_MAX; port++ )) ; do
1416 if ! ss -ln src :$port | grep -q " \<$port \>" ; then
1517 available_ports+=($port )
@@ -34,8 +36,16 @@ elif [ $flag = "-s" ]; then
3436fi
3537if [ " $enable_volume " = " true" ]; then
3638 echo " Creating persistent storage at $PROJECT_STORAGE "
39+
40+ if [ ! -f " $PROJECT_IMG " ]; then
41+ sudo dd if=/dev/zero of=$PROJECT_IMG bs=1M count=$SIZE_MB
42+ sudo mkfs.ext4 $PROJECT_IMG
43+ fi
3744 sudo mkdir -p $PROJECT_STORAGE
38- sudo chmod 777 $PROJECT_STORAGE # tighten later
45+ if ! mount | grep -q " $PROJECT_STORAGE " ; then
46+ sudo mount -o loop $PROJECT_IMG $PROJECT_STORAGE
47+ fi
48+ sudo chmod 777 $PROJECT_STORAGE
3949fi
4050sudo docker build -t $name .
4151if [ " $enable_volume " = " true" ]; then
Original file line number Diff line number Diff line change 66id -u
77
88# Assign the arguments to variables
9- arg1 =$1
9+ name =$1
1010
11- echo " Deleting... $arg1 "
11+ echo " Deleting... $name "
12+
13+ STORAGE_ROOT=" /mnt/storage"
14+ PROJECT_STORAGE=" $STORAGE_ROOT /$name "
15+ PROJECT_IMG=" $STORAGE_ROOT /$name .img"
1216
1317sudo rm /etc/nginx/sites-available/$1 .conf
1418sudo rm /etc/nginx/sites-enabled/$1 .conf
1519sudo docker stop $1
1620sudo docker rm $1
1721sudo docker rmi $1
1822
23+ if mount | grep -q " $PROJECT_STORAGE " ; then
24+ echo " Unmounting volume..."
25+ sudo umount $PROJECT_STORAGE
26+ fi
27+
28+ if [ -d " $PROJECT_STORAGE " ]; then
29+ sudo rm -rf $PROJECT_STORAGE
30+ fi
31+
32+ if [ -f " $PROJECT_IMG " ]; then
33+ echo " Deleting volume image..."
34+ sudo rm -f $PROJECT_IMG
35+ fi
36+
1937sudo systemctl reload nginx
You can’t perform that action at this time.
0 commit comments