Changes

From Amahi Wiki
Jump to: navigation, search
5,065 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.
Mounting your Samba shares locally is useful when you are using Greyhole, and want to write or in any way work with those files locally. Greyhole data should only be accessed through shares, so mounting those shares locally is an easy way to work with Greyhole data safely.==Purpose==
* As Mounting your Samba shares locally within your HDA is useful when you want a process '''root:running within your HDA''' Install the mount_shares_locally initd script:to write data in a way that ends up in a Greyhole-managed share.<u>On Ubuntu</u><div style="border: 1px solid #A3B1BF; padding: The reason is that Greyhole data should '''only be 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.5em 1em; color: #000; background-color: #E6F2FF; margin: 3px 3px 1em 3px; overflow: scroll"> sudo apt-get install cifs-utils curl sudo curl For example, if an app like a downloader gets files from the internet and you want those files to be in a Greyhole-o /etc/initmanaged share, it has to place them into the share, not directly into the operating system, or Greyhole otherwise cannot handle them.d/mount_shares_locally http://dl.amahi.org/mount_shares_locally sudo chmod +x /etc/init.d/mount_shares_locally sudo update-rc.d mount_shares_locally defaults__TOC__ </div>== Download and Setup ==
* As '''root''' (or precede commands with <code>sudo</code>), install the mount_shares_locally initd script:
<u>On === Amahi 10 or greater (Fedora</u>) ===<div style="border: 1px solid #A3B1BF; padding: .5em 1em; color: #000; background dnf install cifs-color: #E6F2FF; margin: 3px 3px 1em 3px; overflow: scroll">utils curl cp /usr/share/hda-o ctl/mount_shares_locally /etc/init.d/mount_shares_locally http://dl.dropbox.com/u/3022105/Amahi/mount_shares_locally
chmod +x /etc/init.d/mount_shares_locally
chkconfig --add mount_shares_locally
</div>
=== Amahi 7/8/9 (Fedora) ===
yum install cifs-utils
curl -o /etc/init.d/mount_shares_locally <nowiki>http://dl.amahi.org</nowiki>/mount_shares_locally.fedora
chmod +x /etc/init.d/mount_shares_locally
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.
 
=== 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>
sudo chmod +x /etc/init.d/mount_shares_locally
sudo update-rc.d mount_shares_locally defaults
 
== 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''').{{Code**Also if you changed the MariaDB root password on your own. :<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$" |Code= nano /etcxargs -d "\n" mkdir -p</init.dpre></mount_shares_locally}}blockquote>
* Create the ''/home/your_username/.smb_credentials'' file. This is a simple text file (use your favorite text editor).
{{Code|Code= nano vi /home/YourHDA_usernameyour_username/.smb_credentials}}
*Enter the following:
<div style="border: 1px solid #A3B1BF; padding: .5em 1em; color: #000; background-color: #E6F2FF; margin: 3px 3px 1em 3px;">
username=your_username
password=your_password
domain=HOME
</div>
'''NOTE:''' your_username and your_password in the .smb_credentials file needs to be the original username and password you created when you installed fedora.
username=your_username password=your_password domain=HOME *Verify the ''.smb_credentials'' is owned by root:root or 1stadminuser:users: ls -al /home/your_username/.smb_credentials :'''NOTE:''' 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 ('''NOT''' ''root''). Also ensure the domain matches the ''Workgroup'' set for shares. *To test your new mounts, you can execute as root user:::<u>Mount</u> systemctl daemon-reload service mount_shares_locally start :<u>Unmount</u> service mount_shares_locally stop :'''service mount_shares_locally startNOTE:'''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<br/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, you need to restart the script by executing as root user (or sudo): service mount_shares_locally restartThis will unmount and remount all your shares, 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 '''service mount_shares_locally stop/mnt/samba/Pictures''' will unmount . When working with files on the local shares.HDA, access them via this share and <u>NOT<br/u>the traditional /var/hda/files/pictures location.
== Uninstall==To uninstall ''mount_shares_locally'NOTE:', do the following as '''root''' If you used : service mount_shares_locally stop rm -rf /etc/rcinit.d/mount_shares_locally rm -rf /home/your_username/.local and smb_credentials chkconfig --del mount_shares_locally rm -rf /mnt/etcsamba/fstab *Now if you choose to mount shares locally in the pastreinstall later, you can remove what you added your machine will be in those files now (<u>DO NOT</u> remove the drive mount lines)a clean state. The above initd script replaces all this.
==Revise mount_shares_locally ==
{{Warning|<div style<nowiki>== Unable to mount localy after upgrading to Amahi6 ==If you try to run mount using this </nowiki>"color:darkred">This is <b>NOT</b> an officially supported script after you upgraded to Amahi6 you might get greeted by this type of errorfor Amahi. Use at your own risk. We cannot guarantee it will work.</div>}}
[root@localhost ~]# /Some apps used by Amahi are used to download files etc/init.d/mount_shares_locally start Mounting Samba Often we want these files to end up in our shares locally: /etc/init.d/mount_shares_locally: line 27: /sbin/mount.cifs: No such file or directory /etc/init.d/mount_shares_locally: line 27: /sbin/mount.cifs: No such file or directory /etc/init.d/mount_shares_locally: line 27: /sbin/mount.cifs: No such file or directory /etc/initLet's say that SickBeard is used to download TV episodes.d/mount_shares_locally: line 27: /sbin/mountYou then have to configure SickBeard to place your new episode somewhere.cifs: No such file or directory A logical place is to save to the landing zone of your Greyhole share which could be ''/etc/init.dvar/mount_shares_locally: line 27: hda/sbinfiles/mountTV''.cifs: No such file or directory /etc/init.d/mount_shares_locally: line 27: /sbin/mount.cifs: No such file or directory /etc/init.d/mount_shares_locally: line 27: /sbin/mountThere are two downsides to this though.cifs: No such file or directory [ OK ]
It* Greyhole is not notified of the fact that a file is added and only discovers it and makes it available in your share after a 's easily fixed by installing 'fsck'', which could take a long time.* Files deleted through apps in this folder don't register a ''delete'' event that Greyhole can pick up and thus only the symlink in the landing zone is removed. The actual file copies remain on disc. Similarly users running Plex Media Server for example will have issues if the clients are allowed to ''delete contents'' and the server is configured to work on the missing dependencylanding zone. I described this issue when packaging Plex a long time ago [[Plex_Media_Server|here]].
{{Code|yum install cifs-utils}}
Now Since Greyhole uses Samba as a layer between the user and itself we would like to keep our writes and deletes to the shares and not the actual landing zone. But since apps (most of them) run as the user ''apache'' it should work fine will not be able to runaccess ''/mnt/samba'', which is the default mount point if you set up ''mount_shares_locally''. This following script retains the function of the original script but also adds a second mount point under ''/mnt/apache'' where the ''apache'' user will have read and write access. I have kept it simple and it will use the same credentials as the ''main'' mount. So only shares available to that user will be available for apache.
{{Code|By doing this apache will now have a place where it is allowed to read and write files to your shares and SickBeard can thus be configured to place the new episode in ''/etcmnt/initapache/TV'' which is then instantly picked up by Greyhole and file copies distributed to the discs in your pool as configured.d/mount_shares_locally start}}
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 -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 With Newer Versions of Greyhole ===
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:
{{Code| 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:
{{Code| rm S-1*}} === Share Permissions ===Ensure your share file and ownership permissions are correct: ls -al /var/hda/filesFor 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 booksIf 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 :'''NOTE:''' Replace ''1stadminuser'' with your admin user name and ''sharename'' with the actual share name.
12,424

edits