Changes

From Amahi Wiki
Jump to: navigation, search
888 bytes added ,  00:41, 10 December 2020
heading =WARNING|
message = This is recommended only for advanced users, proceed with caution.}}
This tutorial is now available as the Amahi [https://www.amahi.org/apps/greyhole-mount-shares-locally Greyhole Mount Shares Locally] application.
==Purpose== Mounting your Samba shares locally within your HDA is useful when you are using Greyhole, and want a process '''running within your HDA''' to write or data in any a way work with those files locallythat ends up in a Greyhole-managed share.  The reason is that Greyhole data should '''only be accessed modified through shares'', not directly onto the local file system, so mounting those shares locally is an easy way to work with Greyhole data safely. For example, if an app like a downloader gets files from the internet and you want those files to be in a Greyhole-managed share, it has to place them into the share, not directly into the operating system, or Greyhole otherwise cannot handle them.  __TOC__
== Download and Setup ==
* As '''root:''' Install (or precede commands with <code>sudo</code>), install the mount_shares_locally initd script:
=== On Amahi 10 or greater (Fedora) === dnf install cifs-utils cp /usr/share/hda-ctl/mount_shares_locally /etc/init.d chmod +x /etc/init.d/mount_shares_locally chkconfig --add mount_shares_locally === Amahi 7 /8/9 (Fedora 19) ===
yum install cifs-utils
curl -o /etc/init.d/mount_shares_locally <nowiki>http://dl.amahi.org</nowiki>/mount_shares_locally.fedora
chkconfig --add mount_shares_locally
::'''NOTE:''' <code>yum</code> (deprecated) has been replaced with <code>dnf</code> as the package manager for Fedora 23 or greater. === On Amahi 6 (Ubuntu 12.04) ===
sudo apt-get install cifs-utils curl
sudo curl -o /etc/init.d/mount_shares_locally <nowiki>http://dl.amahi.org/mount_shares_locally.ubuntu</nowiki>
== Configuration ==
* Edit As '''root''', edit ''/etc/init.d/mount_shares_locally (as user root) in a text editor, and replace ''your_username**Replace ''"***set this string to your username!***"'' (on line 12) with your username. Example '''For example: username="amahi";*The script may require the MariaDB root password be changed: **Please see [[Database Root Password]] for the appropriate login password (change for Amahi 10 '''ONLY''').**Also if you changed the MariaDB root password on your own. vi /etc:<blockquote>Change ''hda'' (line 25) to the appropriate password if needed:<pre style="white-space: pre-wrap; word-break: keep-all;">mysql -u root -p hda -e "select name from shares" hda_production | grep -v "^name$" | xargs -d "\n" mkdir -p</init.dpre></mount_shares_locallyblockquote>
* Create the ''/home/your_username/.smb_credentials'' file. This is a simple text file (use your favorite text editor).
vi /home/1st Admin Useryour_username/.smb_credentials
*Enter the following:
domain=HOME
*Verify the ''.smb_credentials''NOTEis owned by root:''' root or 1stadminuser:users: ls -al /home/your_username and your_password in the /.smb_credentials file needs to be the original username (1st Admin User) and password you created when you installed the OS.
*To test your new mounts, :'''NOTE:''' your_username and your_password in the .smb_credentials file needs to be the original username (1st Admin User) and password you can execute created when you installed the OS ('''service mount_shares_locally startNOT''''' (as root user'')<br/>. Also ensure the domain matches the ''Workgroup'' set for shares.
'''service mount_shares_locally stop''' (*To test your new mounts, you can execute as root user) will unmount the local shares.:::<u>Mount<br/u> systemctl daemon-reload service mount_shares_locally start
:<u>Unmount</u> service mount_shares_locally stop :'''NOTE:''' If you used /etc/rc.local and /etc/fstab to mount shares locally in the past, you can remove what you added in those files now (<u>DO NOT</u> remove the drive mount lines). The above initd script replaces all this.
== Re-mount to Add new shares ==
If you added new share to greyhole via the web admin. This does not automatically mount locally. You Greyhole, you need to restart your mount the script by running '''executing as root user (or sudo): service mount_shares_locally restart'''. This will unmount and remount all your shares, adding reflecting all the new shares you added.
== Where everything is mounted ==
You will find the mounted shares in ''/mnt/samba/*''and should look something like this:<br/><pre>drwxrwx--- 2 your_username users 0 Aug 9 23:31 Booksdrwxrwx--- 2 your_username users 0 Aug 9 23:31 Docsdrwxrwx--- 2 your_username users 0 Mar 2 16:15 Moviesdrwxrwx--- 2 your_username users 0 Aug 9 23:31 Musicdrwxrwx--- 2 your_username users 0 Aug 9 23:31 Picturesdrwxrwx--- 2 your_username users 0 Aug 9 23:31 Publicdrwxrwx--- 2 your_username users 0 Jul 29 02:02 TVdrwxrwx--- 2 your_username users 0 Aug 9 23:31 Videos</pre>For example, your "Pictures" share would be located at '''/mnt/samba/Pictures'''.  <b>NOTE:</b> When working with files on the HDA, access them via this share and <u>NOT</u> the traditional /var/hda/files/pictures location.
== MySQL Problems Uninstall==To uninstall ''mount_shares_locally'', do the following as '''root''': service mount_shares_locally stop rm -rf /etc/init.d/mount_shares_locally rm -rf /home/your_username/.smb_credentials chkconfig --del mount_shares_locally rm -rf /mnt/samba/*Now if you choose to reinstall later, your machine will be in a clean state.
Since Greyhole moved from SQL Lite to MySQL, you may hit a problem where Greyhole and the ==Revise mount_shares_locally script both attempt to start before MySQL in bootup, leading to the services not starting properly. If this happens, you can try this to fix it:==
ls /etc/rc.d/rc3.d/* Look for any entries marked S-1. If there are any, they need to be removed. Run the following as root:  rm S-1*{{Warning|<div style<nowiki>== Alternate mount_shares_locally (UNSUPPORTED)=='''NOTE</nowiki>"color:''' darkred">This is <b>NOT</b> an officially supported script for Amahi. Use at your own risk. We cannot guarantee it will work.</div>}}
Some apps used by Amahi are used to download files etc. Often we want these files to end up in our shares. Let's say that SickBeard is used to download TV episodes. You then have to configure SickBeard to place your new episode somewhere. A logical place is to save to the landing zone of your Greyhole share which could be ''/var/hda/files/TV''. There are two downsides to this though.
Note that this script is based of the Greyhole original one and uses ''/etc/samba/smb.conf'' as the source of your shares and does not load the shares from the database like the old HDA version of the script did. If that behaviour is desired that can be easily added by replacing the lines
<pre style="white-space: pre-wrap; word-break: keep-all;">testparm -s /etc/samba/smb.conf 2>/dev/null | grep "^\[" | grep -v "\[global\]" | grep -v "\[homes\]" | awk -F'[' '{print $2}' | awk -F']' '{print $1}' | xargs -d "\n" mkdir -p</pre>
with
<pre style="white-space: pre-wrap; word-break: keep-all;">mysql -u root -phda p -e "select comment from shares" hda_production | grep -v "^comment$" | xargs -d "\n" mkdir -p </pre>  '''WARNING:''' Please see [[Database Root Password]] for the appropriate login password. ==Troubleshooting===== MySQL Problems === Since Greyhole moved from SQL Lite to MySQL, you may hit a problem where Greyhole and the mount_shares_locally script both attempt to start before MySQL in bootup, leading to the services not starting properly. If this happens, you can try this to fix it:  ls /etc/rc.d/rc3.d/* Look for any entries marked S-1. If there are any, they need to be removed. Run the following as root:
rm S-1*
=== Share Permissions ===
Ensure your share file and ownership permissions are correct:
ls -al /var/hda/files
For example, the correct permissions are:
drwxr-xr-x. 10 root root 4096 Jul 29 17:02 .
drwxr-xr-x. 13 root root 4096 Dec 5 2013 ..
drwxrwxr-x 2 1stadmin users 4096 Dec 5 2013 books
If this is not correct, you will need to change them:
chmod -R 775 /var/hda/files/sharename
chown -R 1stadminuser:users /var/hda/files/sharename
### BEGIN INIT INFO # Provides: mount_shares_locally # Required-Start: $network $local_fs $remote_fs smb mysqld # Required-Stop: $network $local_fs $remote_fs smb # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: mount Samba shares locally ### END INIT INFO username="YOURUSERHERE" if [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions fi start () { uid=`id -u $username` gid=`id -g $username` echo -n $"Mounting Samba shares locally: " mkdir -p /mnt/samba/ mkdir -p /mnt/apache/ cd /mnt/apache/ testparm -s /etc/samba/smb.conf 2>/dev/null | grep "^\[" | grep -v "\[global\]" | grep -v "\[homes\]" | awk -F'[' '{print $2}NOTE:' | awk -F']' Replace '{print $1}' | xargs -d "\n" mkdir -p cd /mnt/samba/ testparm -s /etc/samba/smb.conf 2>/dev/null | grep "^\[" | grep -v "\[global\]" | grep -v "\[homes\]" | awk -F1stadminuser'[' with your admin user name and '{print $2}' | awk -Fsharename']' '{print $1}' | xargs -d "\n" mkdir -p sleep 5 ls -1 | while read d; do /sbin/mount.cifs "//127with the actual share name.0.0.1/$d" "$d" -o credentials=/home/${username}/.smb_credentials,uid=${uid},gid=${gid},file_mode=0660,dir_mode=0770,nobrl,hard,_netdev,iocharset=utf8,noserverino,mfsymlinks /sbin/mount.cifs "//127.0.0.1/$d" "/mnt/apache/$d" -o credentials=/home/${username}/.smb_credentials,uid=`id -u apache`,gid=`id -g apache`,file_mode=0777,dir_mode=0777,nobrl,hard,_netdev,iocharset=utf8,noserverino,mfsymlinks done touch /var/lock/subsys/mount_shares_locally success $"$base startup" echo return 0 } stop () { echo -n $"Unmounting locally mounted Samba shares: " /bin/umount -l /mnt/samba/* /bin/umount -l /mnt/apache/* rm -f /var/lock/subsys/mount_shares_locally success $"$base shutdown" echo return 0 } restart () { stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 ;; esac exit $?
12,424

edits