Last active
September 6, 2022 14:57
-
-
Save manesec/ad08424852fda6870b76f3d4c172eee4 to your computer and use it in GitHub Desktop.
Mount cifs as services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/openrc-run | |
# by manesec. | |
# I need to use docker before mount cifs as docker data. | |
# Here is openrc service config example. | |
# Need to modify /etc/init.d/docker file. | |
#!/sbin/openrc-run | |
depend() { | |
need net | |
} | |
start() { | |
ebegin "Checking mount point ..." | |
check_and_mount | |
eend $? | |
} | |
stop() { | |
ebegin "Unmounting cifs" | |
umount "/mnt/Docker_DATA" | |
umount "/mnt/Download" | |
eend $? | |
} | |
check_and_mount(){ | |
echo "Checking Docker_DATA" | |
mkdir /mnt/Docker_DATA 2> /dev/null | |
while true | |
do | |
if mountpoint -q /mnt/Docker_DATA | |
then | |
break | |
else | |
mount -t cifs -o username=<your_username>,password=<your_password>,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.31.243/NAS_DATA/Docker /mnt/Docker_DATA | |
sleep 1 | |
fi | |
done | |
echo "Checking Download" | |
mkdir /mnt/Download 2> /dev/null | |
while true | |
do | |
if mountpoint -q /mnt/Download | |
then | |
break | |
else | |
mount -t cifs -o username=<your_username>,password=<your_password>,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.31.243/Download /mnt/Download | |
sleep 1 | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment