Geek Freely: nas4free

    Featured Post

    The whole point in this post is to run your own VPN service, and allow you to connect remote devices to your home network.

    To start off yo…

    Showing posts with label nas4free.

    Showing posts with label nas4free.

    If you haven’t already installed and setup MySQL on your NAS4Free box, I suggest you follow this guide:

    We start off by making a for Kodi to access the DB. First we need to login to the MySQL environment to define the user:

    mysql -u root -p

    Note: If MySQL isn’t started then

    Enter the password for  root and then create the Kodi user, here I call them xbmc for nostalgia:

    CREATE USER ‘xbmc’ IDENTIFIED BY ‘xbmc’;

    GRANT ALL ON *.* TO ‘xbmc’;

    quit;

    Create (or add to, if you already have one) an advancedsettings.xml file in your Kodi userdata folder.

    Using nano copy and paste the following information into the advancedsettings.xml file, if there is already content, merge the sections appropriately:

    advancedsettings.xml configuration found in the following location:

    http://kodi.wiki/view/HOW-TO:Share_libraries_using_MySQL/Setting_up_XBMC

    And should look like this:

    mysql

    ***.***.***.***

    3306

    xbmc

    xbmc

    mysql

    ***.***.***.***

    3306

    xbmc

    xbmc

    true

    Replace the two instances of ***.***.***.*** with local network IP address of your NAS4Free server. It is recommended not to use its NetBIOS name, as not all devices may be able to resolve them.

    Save the file as advancedsettings.xml.  Copy this advancedsettings.xml file you just created to the userdata folder of every Kodi install you want to sync .

    If you exported your existing DBs, go ahead and import them.  If you created a fresh DB, scan all your content again, make sure to use the NAS4Free server IP rather than NetBIOS for your shares, as mentioned – not all devices may resolve the NetBIOS.

    As a final note, specifically with OpenELEC and Raspberry Pi, although OpenELEC suggest this for WiFi boxes, set Wait for network before starting Kodi under OpenELEC addon settings, network.

    That is it…you should be good to go.  Let me know how it goes for you, or if you have any issues.

    In some of my previous posts I have written about using NAS4Free and installing various extensions on the system, well it was time to upgrade my NAS4Free but I didn’t have the space on the Operating System drive – so a complete re-install was looming.

    As daunting as it was, it was inevitable that I had to redo everything, but thanks to the new package manager in FreeBSD 10.x this turned out to be an enjoyable exercise.

    The first step I decided to tackle was implementing the MySQL DB on NAS4Free, so I could provide a shared DB for Kodi installs.

    First let’s determine an appropriate location to install the temporary files for installation:

    setenv PKG_TMPDIR /mnt/Data

    Next let’s create the appropriate user and group for the MySQL install in NAS4Free:

    Group

    Name: mysql

    ID: 88

    User

    Name: mysql

    Fullname: mysql

    UserID: 88

    Primary Group: mysql

    NO PASSWORD

    After defining the user to access the MySQL DB, the next step was installing MySQL server, using the following commands:

    pkg install mysql56-server

    rehash

    cd /usr/local

    mysql_install_db

    At this point it is good practice to confirm that MySQL will indeed starts:

    /usr/local/etc/rc.d/mysql-server onestart

    Hopefully everything is good at this point and, the next step is to make sure that MySQL is enabled in NAS4Free:

    nano /etc/rc.conf

    Add the following line to the rc.conf file:

    mysql_enable=”YES”

    Now you should be good to go.

    If you want to configure this for Kodi to use, check out the following guide:

    http://www.geekfreely.com/2015/12/howto-configuring-kodi-to-use-nas4free.html

    So as you may have read in earlier posts – I did a complete reinstall of my NAS4Free server and setup all services running on it. Here in this post I will describe the steps required to install OpenVPN on your NAS4Free server, and configure it to start automatically on bootup.

    First let’s determine an appropriate location to install the temporary files for installation:

    setenv PKG_TMPDIR /mnt/Data/tmp/

    Next let’s install all the required components: curl, expect:

    pkg install openvpn

    pkg install curl

    pkg install expect

    Typing the following command will update yourr shell session with the new commands available based on the installed packages:

    rehash

    Move openvpn file so it does not get executed every time thesystem is started, otherwise your boot process will stop and you will be prompted for a username/password.  NAS4Free executes all the files inside “rc.d” folder on startup.

    mkdir /usr/local/etc/openvpn

    mv /usr/local/etc/rc.d/openvpn /usr/local/etc/openvpn/

    Edit startup settings and add OpenVPN support:

    nano /etc/rc.conf

    Add the following:

    openvpn_enable=YES”

    And ONE of the following, this is based on your VPN provider (check the opvn file contents to determine which to use):

    openvpn_if=”tun”

    openvpn_if=”dev”

    Now retrieve the relevant information from your VPN provider: certificates, location, configuration files etc. Rename the certificate (*.crt) and chosen location (*ovpn) to openvpn.crt and openvpn.conf, and copy *.pem file.

    Install certificates (.crt) and location (.ovpn) files:

    mkdir /usr/local/etc/openvpn

    mv openvpn* /usr/local/etc/openvpn/

    mv *.pem /usr/local/etc/openvpn/

    Make sure the certificate authority configuration line (ca) is set to openvpn.crt by editing the following file:

    nano /usr/local/etc/openvpn/openvpn.conf

    Now it’s time to test OpenVPN and make sure you have an appropriate IP.

    /usr/local/etc/openvpn/openvpn start /usr/local/etc/openvpn/

    curl icanhazip.com

    The curl command should return your NAS’ new WAN IP, and this should be different to your regular WAN IP – as it should be now based on the location file you provided.

    Now we need to configure OpenVP to start and connect on startup, so let’s create an auto-sign-on script, and make it executable:

    nano /usr/local/etc/openvpn/autosignon

    chmod +x autosignon

    Paste the following, and edit username and password to match your details, for your VPN provider:

    #!/usr/local/bin/expect -f

    set force_conservative 0

    spawn /usr/local/etc/openvpn/openvpn start /usr/local/etc/openvpn/openvpn.conf

    match_max 100000

    expect -exact “Enter Auth Username:”

    send “YOUR USERNAME”

    send “\r”

    expect -exact “Enter Auth Password:”

    send “YOUR PASSWORD”

    send “\r”

    expect eof

    Add the following command script PreInit (System|Advanced|Command Scripts) via your NAS4Free web interface:

    /usr/local/etc/openvpn/autosignon

    Reboot your machine and you should be automatically connected to your VPN service.

    Set the temporary directory for the packages, as well as the site to fetch packages from (if you are installing onto a 32 bit system change “amd64″ to “i386″):

    setenv PKG_TMPDIR /mnt/Data/Extensions/tmp/

    setenv PACKAGESITE “http://ftp6.us.freebsd.org/pub/FreeBSD-Archive/ports/amd64/packages-9.0-release/Latest/”

    Install OpenVPN:

    pkg_add -rv openvpn

    Move openvpn file so it does not get executed every time when system is being started, otherwise your boot process will get stopped and you will be asked for a username/password.  NAS4Free executes all the files inside “rc.d” folder on startup.

    mv /usr/local/etc/rc.d/openvpn /usr/local/etc/openvpn/

    Install Certificates and .ovpn files.

    mkdir /usr/local/etc/openvpn

    Download your certificates *.crt as well as *.ovpn , rename them to *.crt->openvpn.crt and *.ovpn->openvpn.conf copy them using WinSCP to /usr/local/etc/openvpn/

    Once copied edit the openvpn.conf and you should see something like that:

    client

    dev tun

    proto udp

    remote 11.170.97.173 443 # – Your server IP and OpenVPN Port

    resolv-retry infinite

    nobind

    tun-mtu 1500

    tun-mtu-extra 32

    mssfix 1450

    persist-key

    persist-tun

    ca openvpn.crt

    auth-user-pass

    comp-lzo

    verb 3

    Add the following line to openvpn.conf, so passwords aren’t stored in memory:

    auth-nocache  Don’t use auth-nocache, as renegotiation after timeout will fail.

    Just make sure after “ca” there is openvpn.crt, also check the 2nd line if you have got dev tun or dev tap

    Test OpenVPN connection:

    /usr/local/etc/openvpn/openvpn onestart /usr/local/etc/openvpn/openvpn.conf

    Download the following torrent to make sure your legal torrents are downloaded privately:

    Edit rc.conf to enable OpenVPN.  Open up your NAS’ web interface and head to System > Advanced > rc.conf and add the following variables:P

    openvpn_enable with a value of YES

    openvpn_if with a value of tun or tap depending on the contents of openvpn.conf

    Now we need to make it autostart, so back to SSH:

    pkg_add -r expect

    nano /usr/local/etc/openvpn/autosignon

    In the file just insert:

    #!/usr/local/bin/expect -f

    set force_conservative 0

    spawn /usr/local/etc/openvpn/openvpn start /usr/local/etc/openvpn/openvpn.conf

    match_max 100000

    expect -exact “Enter Auth Username:”

    send — “YOUR USERNAME!\r”

    expect -exact “Enter Auth Password:”

    send — “YOUR PASSWORD!\r”

    expect eof

    Save your changes and make that script executable by running the following command:

    chmod +x autosignon

    AUTOSTART OPENVPN

    In NAS4Free webGUI, navigate to: “System|Advanced|Command scripts” and insert the following start-up command (PreInit):

    /usr/local/etc/openvpn/autosignon

    CONFIGURE FIREWALL

    So this is a bit hit or miss for me, I almost feel like I am having to restart my NAS4Free box before I see the changes from the firewall applied.

    My VPN provider doesn’t have a list anymore for which IPs they assign, so I just have to kinda guess.

    The purpose of the firewall is to provide detection if the event of the VPN service going down, and by protection we mean – no external connection.

    If you wish to test your NAS4Free box IP directly from command line, install curl.

    pkg_add -rv curl

    Then enter the following:

    curl ifconfig.me

    But you can also check your torrent client directly too!

    9/15/2014 Update:  CHange torrent IP tracking address.

    I have updated these guides for NAS4Free version 10.2.x, check them out here:

    So I have just set this up, and I have not tested it thoroughly yet, but I wanted to get it down on paper so I don’t forget.  As with some of my other posts this is the merging of other peoples work and findings.

    NOTE THIS IS FOR A FULL INSTALL OF NAS4FREE

    For MySQL setup on NAS4Free I followed this guide:

    And for XBMC setup I followed this guide:

    Here is all that information put into a single guide:

    Installing and Setting Up MySQL

    Create a directory to store MySQL data files, in my case I create a sub-directory in /mnt/data/db/mysql to store database files.

    # mkdir -p /mnt/data/db/mysql

    where /data –

    is Mount point name.  Provide full rights to this location:

    # chmod 777 /mnt/data/db/mysql

    By default the MySQL server on NAS4Free stores database files in /var/db/mysql which does not exist at this point, so let’s make a symbolic link in that directory:

    # ln -s /mnt/data/db/mysql /var/db/mysql

    Create the group and user ‘mysql’ using the NAS4Free WebGUI, it is important because NAS4Free will forget about the users created on command line after reboot.

    Group

    Name: mysql

    ID: 88

    User

    Name: mysql

    Fullname: mysql

    UserID: 88

    Primary Group: mysql

    NO PASSWORD

    Now install MySQL 5.5:

    # pkg_add -r mysql55-server

    # rehash

    Execute the following command to create default databases and tables, and upgrade:

    # cd /usr/local/bin

    # mysql_install_db

    # mysql_upgrade

    Give all permissions to the user and group mysql for /mnt/data/db

    # chown -R mysql:mysql /mnt/data/db/mysql/

    Execute

    # mysqld_safe &

    Now, this created  .err

    and

    .pid

    into

    /mnt/data/db/mysql

    folder.  Check errors written into .errAdd mysql_enable=”Yes”

    into /etc/rc.conf.  GUI is preferable to make this change (select System | Advanced | rc.conf), but the following command works just as well:

    # echo ‘mysql_enable=”YES”‘ >> /etc/rc.conf

    I found that after a NAS4Free upgrade the command line option no longer existed.  I recommend doing it via GUI.

    Reboot your box and type the following command to make sure MySQL is running:

    # top

    If it is not running, type the following command to start MySQL:

    # /usr/local/etc/rc.d/mysql-server start

    Secure MySQL using the following wizard:

    # mysql_secure_installation

    Log into MySQL:

    # mysql -u root -p

    You are now in mysql administration, conduct the following commands in MySQL to allow XBMC access.

    # CREATE USER ‘xbmc’ IDENTIFIED BY ‘xbmc’;

    # GRANT ALL ON *.* TO ‘xbmc’;

    # quit;

    Configuring XBMC to use NAS4Free MySQL DB

    Export your music and your video directories, you can to this as separate or single file, I tried to do separate which is the suggested, but I have no idea where the files where put – so I just started afresh.  If you want to try and retain your current “master” DBs, follow the steps here:

    Otherwise you can just continue on with this guide.

    Create (or add to, if you already have one) an advancedsettings.xml file in your XBMC userdata folder.

    Using nano copy and paste the following information into the advancedsettings.xml file, if there is already content, merge the sections appropriately:

    advancedsettings.xml configuration found in the following location:

    and should look like this:

    mysql

    ***.***.***.***

    3306

    xbmc

    xbmc

    mysql

    ***.***.***.***

    3306

    xbmc

    xbmc

    true

    Replace the two instances of ***.***.***.*** with local network IP address of your NAS4Free server. It is recommended not to use its NetBIOS name, as not all devices may be able to resolve them.

    Save the file as advancedsettings.xml.  Copy this advancedsettings.xml file you just created to the userdata folder of every XBMC install you want to sync with.

    If you exported your existing DBs, go ahead and import them.  If you created a fresh DB, scan all your content again, make sure to use the NAS4Free server IP rather than NetBIOS for your shares, as mentioned – not all devices may resolve the NetBIOS.

    One of the first changes you’ll want to make, on your XBMC systems, is to alter what XBMC does in

    response to you pressing play on a file. By default XBMC simply plays

    the file from the beginning. Since we now have an XBMC system that

    remembers our place across multiple machines, we want XBMC to prompt us.

    Navigate to Settings | File Lists and set the Default select action to Choose. We want XBMC to ask us what to do when we’re opening a file instead of automatically playing it from the start.

    As a final note, specifically with Openelec and Raspberry Pi, although Openelec suggest this for WiFi boxes, set Wait for network before starting XBMC under Openelec addon settings, network.

    That is it…you should be good to go.  Let me know how it goes for you, or if you have any issues.

    Updates from lindsay added:

    Additional updates from lindsay:

    Optimizing the DB using a cron, I used the following command to test before making the cron:

    # mysqlcheck -os -u xbmc -pxbmc –all-databases

    So I was having a little trouble with my transmission setup in NAS4Free.  I recently moved house and did a bunch of cleanup on my servers, reinstall of NAS4Free and setting up appropriate users and groups.  Unfortunately this meant that my torrent client, used for downloading Linux distributions, was unable to move the completed file to my designated folder.  Solution, change the transmission user to run as me and not transmission (the default).

    First of all stop the transmission service, next change the transmission folders to the appropriate user and group (I kept the transmission group) using chmod.

    Then edit the following file:

    nano /etc/rc.d/transmission

    And change the following loone:

    transmission_user=${transmission_user:-“transmission”}

    To whoever you want:

    transmission_user=${transmission_user:-“whoever_you_want”}

    Restart your NAS box, make sure all rights are the same on the modified folders.  Initiate a torrent download of Ubuntu, check that the partial file have the correct username and group.

    Enjoy

    The other day I bought a 4TB disk for my NAS, I needed to move all my data from an existing 2TB disk to the new 4TB disk.  I used TeraCopy () for this, as not only does it appear to move the data quicker than Windows Explorer, but it can validate it after transfer.

    The main problems I had related to the fact that I wasn’t simply adding a disk, I was replacing a disk.

    First of all I used a free box that I had to run live NAS4Free and setup the disk.  The sequence for encrpyting a disk in NAS4Free is as follows:

    Add Disk

    Create your encrypted volume using the previously added disk : This step will automatically ‘attach’ this volume

    Format this encrypted volume

    Add a Mount Point using this encrypted volume

    It’s very important to follow this order, I tried to do 3 before 2 and always ran into problems mounting.

    Once the disk was added I was able to transfer the data, the next step was waiting 24hrs.

    After all the data had transferred it was time to remove the old drive and replace it with the new one.

    Before removing the drive physically I deleted the following:

    I did not remove encrypted reference, as I thought it would delete the contents of the drive, which I wanted as backup until I had confirmed the new drive was working.

    Next step was to physically remove the drive and replace it with the new one.  Once the drive was in I had to do the following steps to get everything up and running:

    Add disk (note it is encrypted)

    Remove previous encypted disk information

    Add new disk to encryption list (NOTE: DO NOT INITIALIZE)

    Create Mount Point (NOTE: I had to fsck/check-disk first, as I was receiving errors when mounting)

    Add CIFS/SMB share

    I did a couple of reboots to make sure everything was coming up as expected.  At this point I took a new backup of the NAS4Free configuration.

    Firstly, I have to say I cannot take all the credit for this… I got a lot of information from , who in turn got it from NAS4Free wiki.

    However, I did find some problems along the way, and as usual I want to keep it somewhere I can get easy access to in future – this blog.  Please also note, this will solve any m4a and flac transcoding issues, and possibly other codecs.

    The whole process relies on you setting up a jail in NAS4Free so that the changes are not lost on reboot (since this is an embedded guide).

    Lets start of with configuring NAS4Free to complete this task:

    SSH into your NAS4Free box using putty or similar. NOTE: Change all reference to /mnt/data to the mountpoint on your NAS where you are going to store the jail.

    The base system has to be downloaded to make sure you get all

    the necessary binaries, config files and scripts. To download it you can

    just copy paste the following commands into the ssh shell.

    The last command for fetching lib32 is not needed if you are running NAS4Free on an 32bit system.  The following two commands extract the base system into the proto folder inside the jail.

    NOTE: Obviously exchange EST for

    your own time=zone. Next we will configure the mounts that the jail is

    going to be able to access.

    NOTE: Change DataDisk1 for the mounts that you have on the NAS

    that you want to be accessible in the jail.

    Copy into the fstab file the following lines:

    /mnt/data/DataDisk1 /jail/proto/mnt/DataDisk1 nullfs rw 0 0

    The drive is mounted read write for playlist, comments, ratings, podcast access from Subsonic.

    The next part of the

    configuration is to create the rc.conf file.

    Copy into the rc.conf.local the following lines:

    jail_enable=”YES” # enable jails YES|NO

    jail_list=”proto” # name of the jails to start “proto www…”

    jail_proto_rootdir=”/jail/proto” # path to our jail

    jail_proto_hostname=”proto” # hostname

    jail_proto_ip=”192.168.0.30″ # ip of the jail, replace with a ip in the same subsystem as your NAS

    jail_proto_interface=”re0″ # Network Interface to use, replace with your NAS interface name

    jail_proto_devfs_enable=”YES” # use devfs

    jail_proto_mount_enable=”YES” # mount YES|NO

    jail_proto_fstab=”/jail/conf/fstab.proto” # File with Filesystems to mount

    Copy into jail_start the following lines:

    #!/bin/tcsh -x

    #mounting to /jail

    mkdir /jail

    mount_nullfs /mnt/data/jail /jail

    # copy jail binaries to /usr, not needed if N4F is 454 or up

    # because Daoyama include needed files, uncomment if you use low .454 version

    # cp -r /jail/conf/root/ /

    # link config files to /etc

    ln -s /jail/conf/rc.conf.local /etc

    #start all jails

    /etc/rc.d/jail start

    Make the start-up script executable with the following command:

    And to make it run each time the NAS server is started, add the following via the webgui under System|Advanced|Command Scripts.

    Command: /mnt/data/jail/conf/jail_start

    Type: PostInit

    Save and apply, and reboot your server. After a successful reboot check your new jail via SSH using the jls command, you should see something like this:

    JID             IP Address                   Hostname                      Path

    1                192.168.1.201             proto                              /jail/proto

    And that’s how you setup a FreeBSD jail on NAS4Free embedded.

    Enter the jail with the following command (based on the output of example jls above we use 1):

    The pkg_add command doesn’t function

    properly inside the jail. To fix this you have to run the following

    command NOTE: I am using a 64-bit install:

    Now start installing the packages required by

    Subsonic:

    Now install libmp3lame so that ffmpeg can use it for transcoding:

    Now compile and install your own ffmpeg with libmp3lame enabled, (remember –enable-libmp3lame during make config):

    Create the folders and download/extract subsonic standalone.

    Enter the following

    command while you are still inside the jail to see if subsonic starts.

    If subsonic started as it should you can connect to it via the

    browser at the following adress: Jail-IP:4040, default username is

    admin, and password admin.

    To make it run each time the NAS server is started add via the webgui under: System|Advanced|Command Scripts.

    Command: jexec 1 /var/subsonic/standalone/subsonic.sh

    Type: PostInit

    Save and apply, and reboot your server. After a successful reboot you can check your Subsonic install via http://Jail-IP:4040

    If your Subsonic installation has problems with the audio (the java

    install couldn’t see your audio dev) install

    alsa-plugins via the following command:

    ENJOY!

    And if you want to access your new service on your android device, why not try out the official

    (4/17/2013 Updated for Subsonic 4.8)

    (5/10/2013 Updated based on fsbruva’s comments http://forums.nas4free.org/viewtopic.php?f=79&t=3166&p=19759#p19759)

    So, for the longest time I tried to get

    working with iPhone and my home server (my problem was I was trying to use FTPS, instead of SFTP).  Using FileZilla I could always successfully connect using “require explicit FTP over TLS”:

    Based on this I figured it was an issue with the iPhone apps, I think it was error 425 (cannot build data connections).  Then I thought it was my , since I used , I figured maybe something was screwy – a draw back of bleeding edge geeky stuff, you question it.  Anyway, it was a port configuration issue by me.

    I needed to open port 22, not 21.  I also had to connect using different settings SFTP.

    As for iPhone client, I have tried a few; FTPOnTheGo, Files Connect, and Easy FTP.  Of them all I like FTPOnTheGo – I should probably look into the options again – considering iPad clients too.

    Since I originally stater this investigation and setup, I treated myself to a new router .  I might write a quick review on it actually…

    Previously on FreeNAS 0.7.2 I had to use the following configuration

    to get additional speed on my transfers, and those benefits were only

    when copying to the NAS, not from it.

    Everything was acceptable on FreeNAS 0.7.2, however updates had

    halted, FreeNAS took a leap to version 0.7.5, which there is no official

    upgrade route from 0.7.2, then 0.7.5 seems to have branched off into

    NAS4Free.

    So what to do?

    I changed my FreeNAS 0.7.2 installation into an embedded install,

    then upgraded to 0.7.5.  At this point I had to re-mount all my drives

    (backup configurations at every stage).  I was able to check the

    permissions I had configured by checking my old configuration_###.xml

    files.  Within minutes I had FreeNAS 0.7.5 running, additional benefits

    were already there – however the plan was to move to NAS4Free since I

    see FreeNAS support halting completely in the future.

    Upgrading to NAS4Free, while experimental, was the simplest process:

    Make a backup of your configuration. (Web GUI ‘System|Backup/Restore’)

    Modify the configuration by changing the upper most

    and the most lowest string

    on the configuration to

    and

    respectively.

    Change the version to 1.0.

    Burn the Live CD (ISO) and install NAS4Free.

    Restart the server without the CDROM.

    Import your modified configuration (Web GUI ‘System|Backup/Restore’) and restore.

    At this point I was able to remove all the extra auxiliary parameters for SAMBA.

    Update:  NAS4Free has an upgrade path from FreeNAS now.

    Notes can be found at the following location:

    This version supports upgrading from FreeNAS 0.7.2 or 0.7.5.

    The supported lowest config version is 8.9. (0.7.2.5246)

    Subscribe to:

    Labels

    Blog Archive

    Links

    Leave a Reply

    Your email address will not be published.