Created
December 19, 2018 05:57
-
-
Save je8n/f2474b0c558473918dfa4b538651ef51 to your computer and use it in GitHub Desktop.
This file contains 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
### Serkan Özdemir | |
### 30.07.2018 | |
### Kullanım; | |
### <script> //<remoteipadress>/<sharedfoldername> <linuxmountfolder> <username> <password> | |
### sh ./mountwindir.sh //10.10.10.10/sharedfolder /mnt/test <username> <password> | |
### Eğer şifre girilmez ise soracaktır. If password not entered, asked next steps. | |
#!/bin/bash | |
remote=$1 | |
local=$2 | |
username=$3 | |
if [ -z "$4" ]; then | |
echo "-- Login Password :" | |
read -s password | |
else | |
password=$4 | |
fi | |
if [ ! -d "$local" ]; then | |
sudo mkdir $local | |
echo "-- Directory Created" | |
sudo chmod 777 -R $local | |
echo "-- Directory permissions enabled" | |
else | |
echo "-- Directory already exist" | |
fi | |
mounted=0 | |
if [ $(mount | grep $local -c)>0 ]; then | |
echo "-- this folder is already mounted" | |
mounted=1 | |
else | |
mount -t cifs $remote $local -o username=$username -o password=$password | |
echo "-- successfully mounted $remote in $local" | |
fi | |
mountnow="n" | |
if [ $mounted = 1 ]; then | |
read -p "-- if you umount directory and mount in connection (y n)" mountnow | |
fi | |
if [ $mountnow = "y" ]; then | |
umount $local | |
echo "-- umounted directory" | |
mount -t cifs $remote $local -o username=$username -o password=$password | |
echo "-- successfully mounted $remote in $local" | |
else | |
echo "-- No Any Changes Mount Directory in $local" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment