#!/bin/bash function initUI() { while [ true ] do more -16 /opt/TAU.txt echo "" echo "-------------------------" echo "---NAS-MANAGEMENT-TOOLS--" echo "--------Ver:0.2----------" echo "--------by OT-22---------" echo " = HEXO-TOOL =" echo " 1. start server " echo " 2. upload post" echo " 3. auto update " echo " 4. auto deploy " echo " = BACKUP-TOOL = " echo " 5. !!! BACKUP SYSTEM IMG And Resize to custom size Then compress to TGZ !!! " echo " 6. !!! BACKUP SYSTEM IMG Without Compress !!! " echo " = SYSTEM-TOOL = " echo " 7. Resize File System When you Recovery Backup " echo " = DOCKER-TOOL = " echo " 8. Moving Docker Data to p2; Recovery and Backup Docker Data " echo " 9. Install Docker cotainer " echo " " echo " Please set HEXO PATH by ' vi /opt/d.sh ' edit ' hexo = ' " echo " != Backup instructions =!" echo "!= Backup 1 step will generate a file system copy in ext format =!" echo "!= Backup 2 step will Check the correctness of the ext file system,Make sure your backup and resize operate is available =!" echo "!= Backup 3 step will resize the copy and generate a backup image =!" echo "!= FOR MORE, PLEASE CHECK https://www.in7.xyz " echo " When you type path in this scrip,Dot not type / at the end of the path character,Such as '/root/data/' is invalid,You should ''/root/data' " echo " " echo -n " Please enter : " echo " " ######################## hexo='/sharedfolders/ud/hexo/blog' ######################## read num if [ -z $num ];then exit 0 elif [ $num = 1 ];then startServer elif [ $num = 2 ];then uploadpost elif [ $num = 3 ];then autoUpdate startServer elif [ $num = 4 ];then autoDeploy elif [ $num = 5 ];then backup1 elif [ $num = 6 ];then backup2 elif [ $num = 7 ];then resizesystem elif [ $num = 8 ];then dockermove elif [ $num = 9 ];then dockerinstall elif [ $num = 11 ];then liltest ## elif [ $num = # ];then else echo "Input error !!!!!!" fi done } function read_yes_no () { printf "[yes|no] " read yesno; while [[ "${yesno}" != "yes" && "${yesno}" != "no" ]] do printf "please answer [yes|no] " read yesno; done if [[ "${yesno}" == "no" ]]; then return 1; else return 0; fi } function startServer() { cd $hexo hexo s } function uploadpost() { cd $hexo read -t 20 -p "input your title " a hexo new $a } function autoUpdate() { cd $hexo hexo clean hexo g hexo s } function backup1() { read -t 20 -p "Your backup path is " backup0 read -t 20 -p "Your IMG size(Mbyte) is " size echo " Your Path is $backup0 " echo " Your Size is $size " cd $backup0/ sync dd if=/dev/mmcblk1p1 of=$backup0/p0.ext bs=1M e2fsck -fy $backup0/p0.ext resize2fs -M $backup0/p0.ext resize2fs $backup0/p0.ext $size dd if=/dev/mmcblk1 of=$backup0/p.img bs=1M count=16 dd if=$backup0/p0.ext of=$backup0/p.img bs=1M seek=16 mv p.img omv-p2.img tar zcvf omv-p2.tar.gz omv-p2.img } function backup2() { read -t 20 -p "Your backup path is " backup0 echo " Your Path is $backup0 " cd $backup0/ sync dd if=/dev/mmcblk1p1 of=$backup0/p0.ext bs=1M e2fsck -fy $backup0/p0.ext resize2fs -M $backup0/p0.ext dd if=/dev/mmcblk1 of=$backup0/p.img bs=1M count=16 dd if=$backup0/p0.ext of=$backup0/p.img bs=1M seek=16 } function autoDeploy() { cd $hexo hexo clean hexo g hexo d } function resizesystem() { resize2fs /dev/mmcblk1p1 } function dockermove() { echo " Your Docker Path DON'NOT contain ./docker,It should be previous file of docker data. " echo " Such as your docker file is '/home/docker',Then you should type '/home' " echo " The step is : BACKUP------>RECOVERY------>COPY------>MOVE " read -t 20 -p "input your docker path " p2 echo " Your Path is $p2/docker " service docker stop echo " BACKUP " echo " backup Docker Data? " if read_yes_no; then cd $p2/docker tar -cvpzf $p2/docker.tgz * else echo " Let's do next " echo " " fi echo " RECOVERY " echo " If you use docker data backup as a new docker data or not? " echo " Make sure you put docker.tgz in PATH " echo " Then you may be need to delete present docker data,YOU NEED DELETE? " if read_yes_no; then echo " TELL ME YOU ARE LUCID GUY " echo " Now I will delete your docker data,continue????????????? " if read_yes_no; then rm -rf $p2/docker else echo " Confirming you dont have docker data in target path " echo " " fi else echo " Confirming you dont have docker data in target path " echo " " fi echo " I will RECOVERY your Docker data from docker.tgz " if read_yes_no; then mkdir -p $p2/docker chmod -R 771 $p2/docker tar -xvpzf $p2/docker.tgz -C $p2/docker else echo " May be you already exsited a docker data " echo " " fi echo " COPY " echo "If you copy local docker data as a new docker data or not?" if read_yes_no; then cp -avx /var/lib/docker $p2 else echo " Let's do next " echo " " fi echo " REDIRECT " echo " Final Step,The default Docker data will set to Your docker data that you want to. " echo " Confirm execution? " if read_yes_no; then echo " Activating all containers ? " echo " it need to restart your server, Your server will POWER OFF SOON. " if read_yes_no; then echo "Nextly,Docker data will be moved. " echo "REDIRECT---->START CONTAINER---->REBOOT SERVER " rm -rf /var/lib/docker ln -s $p2/docker /var/lib/docker dockerinstall reboot else echo "Nextly,Docker data will be moved. " rm -rf /var/lib/docker2 ln -s $p2/docker /var/lib/docker exit 0 fi else service docker start exit 0 fi } function dockerinstall() { echo " Install.............. " docker run -d --name portainer -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data -v /public:/public --restart=unless-stopped portainer/portainer:linux-arm64 docker run -d --name=calibre-web -e PUID=1000 -e PGID=1000 -e TZ=Asia/Shanghai -p 8083:8083 -v /home/docker/calibreweb:/config -v /sharedfolders/hd/ebook:/books --restart unless-stopped gsp8181/calibre-web IMAGE_NAME=80x86/filebrowser WEB_PORT=8866 FB_AUTH_SERVER_ADDR="127.0.0.1" docker run -d --name fb --restart=unless-stopped -e PUID=$UID -e PGID=$GID -e WEB_PORT=$WEB_PORT -e FB_AUTH_SERVER_ADDR=$FB_AUTH_SERVER_ADDR -p $WEB_PORT:$WEB_PORT -v /home/docker/fb:/config -v /:/myfiles --mount type=tmpfs,destination=/tmp ${IMAGE_NAME}:arm64 docker run -d --name=baidupcs --restart always -v /sharedfolders/ud/DownLoad:/app/Downloads -v /home/docker/BaiduPCS:/app/.config/BaiduPCS-Go -p 5299:5299 80x86/baidupcs:latest echo " Install Complete " } clear initUI