📜 ⬆️ ⬇️

Automatic mount of smb folder for N900 when connected to a specific network

A week after the purchase of the Nokia n900, I had a desire to make sure that when I came home and connected to my network - my phone automatically mounted the folder from the laptop that does not turn off at night.

Decision:

To connect the smb folder with support for Russian names, you must do the following:

1. Install two packages:
  - kernel-module-nls-utf8
    - kernel-module-cifs 

')
2. Under the root execute two commands:
echo start on startup > /etc/ event .d/cifs<br>echo exec modprobe cifs >> /etc/ event .d/cifs <br><br> * This source code was highlighted with Source Code Highlighter .


3. Create a folder in which the partition will be mounted:
mkdir /home/user/MyDocs/mountpoints<br>mkdir /home/user/MyDocs/mountpoints/notebook-upload <br><br> * This source code was highlighted with Source Code Highlighter .


4. Add to the address /etc/network/if-up.d/ a script called 00_mount_notebook_upload with the following content:

#!/bin/sh

set -e

ICD_CONNECTION_NAME=$(gconftool-2 -g "/system/osso/connectivity/IAP/$ICD_CONNECTION_ID/name" )

if [ "$IFACE" = wlan0 ]; then
if [ "$ICD_CONNECTION_NAME" = "<your ssid>" ]; then
mount -t cifs //<server>/<folder> /home/user/MyDocs/mountpoints/notebook-upload/ -o user=<username>,pass=<password>,ip=<serverip>,codepage=cp1251,iocharset=utf8
fi
fi

* This source code was highlighted with Source Code Highlighter .


5. At the address /etc/network/if-down.d/ create a script by disabling the folder when disconnected from the network named 00_umount_notebook_upload with the following content:

#!/bin/sh

set -e
ICD_CONNECTION_NAME=$(gconftool-2 -g "/system/osso/connectivity/IAP/$ICD_CONNECTION_ID/name" )

if [ "$IFACE" = wlan0 ]; then
if [ "$ICD_CONNECTION_NAME" = "<your ssid>" ]; then
umount /home/user/MyDocs/mountpoints/notebook-upload/
fi
fi


* This source code was highlighted with Source Code Highlighter .


Instead of parameters in <> specify your data.

6. Set the execution rights for scripts:
chmod 755 /etc/network/ if -up.d/00_mount_notebook_upload
chmod 755 /etc/network/ if -down.d/00_umount_notebook_upload


* This source code was highlighted with Source Code Highlighter .


7. Reconnect the network connection and check for files in the mounted folder.

Source: https://habr.com/ru/post/99052/


All Articles