2013年11月15日 星期五

Installing MySQL with phpMyAdmin On NAS4Free

* Platform OS        : FreeBSD 9.1-RELEASE-p5 (kern.osreldate: 901000)
* Version               : 9.1.0.1 - Sandstorm (revision 847)
* Build date           : Sun Aug 18 03:49:41 CEST 2013

Install MySQL server

First.
ADD a new Group on WebGUI and called mysql
ADD a new User on WebGUI and called mysql
Set the Set the account's primary group to mysql.

§  Log into NAS4Free using SSH or Telnet, for instance by using Putty
§  Create the MySQL data directory:
# mkdir /<directory_name>/db/mysql
§  Create the MySQL symbolic link:
# ln -s /<directory_name>/db/mysql /var/db/mysql
§  Change the owner:
# chown -R mysql:mysql /<directory_name>/db/mysql/
§  Allow anyone access the temporary directory:
# chmod 777 /tmp
# chmod 777 /var/tmp
# chmod 777 /ftmp
§  Install MySQL server:
# pkg_add -r mysql50-server
§  Create database:
# /usr/local/bin/mysql_install_db --user=mysql
# chown -R mysql /var/db/mysql
§  Start MySQL:
# /usr/local/bin/mysqld_safe &
§  Change the password:
# /usr/local/bin/mysqladmin -u root password 'root_password'
§  Edit config file:
# vi /etc/rc.conf
§  Start MySQL automatically by adding contents like that in this file:
mysql_enable="YES"
§  Reboot

Install PHP

§  The file cause WebGUI crash, Backup this file:
cp /usr/local/lib/libxml2.so.5 /tmp/libxml2.so.5
§  Install PHP packages:
# pkg_add -r php5-extensions
# pkg_add -r php5-xmlrpc
# pkg_add -r php5-gettext
# pkg_add -r php5-mcrypt
# pkg_add -r php5-mysql
# pkg_add -r php5-mbstring
# pkg_add -r php5-mysqli
§  Fix WebGUI crash problem:
# mv /usr/local/bin/php /usr/local/bin/php-cli
# cp /usr/local/bin/php-cgi /usr/local/bin/php
# rm /usr/local/lib/libxml2.so.5
# cp /tmp/libxml2.so.5 /usr/local/lib/libxml2.so.5

Install phpMyAdmin

  • Create the phpMyAdmin directory:
# mkdir /<directory_name>
§  Extract the contents of the phpMyAdmin to the new directory. Run the following command in Linux terminal.
# cd /<directory_name>
# fetch http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.9/phpMyAdmin-4.0.9-all-languages.tar.gz
# tar -zxvf phpMyAdmin-4.0.9-all-languages.tar.gz
§  Create the phpMyAdmin symbolic link:
# ln -s /<directory_name>/phpMyAdmin-4.0.9-all-languages /<directory_name>/phpMyAdmin
# ln -s /<directory_name>/phpMyAdmin /<web_directory>/phpMyAdmin
§  Access phpMyAdmin:
http://< NAS4Free_IP >/phpMyAdmin

2013年6月1日 星期六

Running Dropbox at Startup on QNAP NAS

* Model              : SS-439 Pro
* Version            : 3.8.3 build0426
* Date               : 2013/04/26

Make a new share on QNAP NAS and called Dropbox

Declaring a Dropbox QPKG which launches script at startup.
§  Log into QNAP device using SSH or Telnet, for instance by using Putty
§  Edit QPKG config file:
# vi /etc/config/qpkg.conf
§  Declare a new Dropbox package by adding contents like that in this file:
[Dropbox]
Name = Dropbox
Version = 2.0.22
Author = Dropbox
Date = 2013-05-06
Shell = /share/MD0_DATA/.qpkg/Dropbox /Dropbox.sh
Install_Path = /share/MD0_DATA/.qpkg/Dropbox
Enable = TRUE
Note: if NAS doesn't have /share/MD0_DATA (i.e. is a one-drive NAS), put the right directory into the Shell and Install_Path variables.
§  Create the Dropbox package directory:
# mkdir -p /share/MD0_DATA/.qpkg/Dropbox
§  Extract the contents of the Dropbox package to the new directory. Run the following command in Linux terminal.
# cd /share/MD0_DATA/.qpkg/Dropbox
# wget https://www.dropbox.com/download?plat=lnx.x86 --no-check-certificate
# tar -xzf dropbox-lnx.x86-2.0.22.tar.gz
§  Create the Dropbox symbolic link:
# ln -sf /share/MD0_DATA/Dropbox /share/MD0_DATA/.qpkg/Dropbox/Dropbox
§  Create the .dropbox directory:
# mkdir -p /share/MD0_DATA/.qpkg/Dropbox/.dropbox
§  Create the Dropbox script with the contents:
# vi /share/MD0_DATA/.qpkg/Dropbox/Dropbox.sh
§  To be able to enable and disable the Dropbox feature edit the script
#!/bin/sh

CONF=/etc/config/qpkg.conf
QPKG_NAME="Dropbox"

RETVAL=0
QPKG_BASE=
HOME=

DROPBOX_USER="admin"
DAEMON=.dropbox-dist/dropbox

LOCALE=en_US.UTF-8

HOMEDIR=`getent passwd $DROPBOX_USER | cut -d: -f6`

case "$1" in
  start)
 if [ `/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF` = UNKNOWN ]; then
       /sbin/setcfg $QPKG_NAME Enable TRUE -f $CONF
 elif [ `/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF` != TRUE ]; then
       echo "Dropbox is disabled."
       exit 1
 fi
                 PID=`ps -ef | awk '/[d]ropbox/{print $1}'`
        if [ -z $PID ] ; then
            echo "Starting Dropbox..."
        else
            echo "Dropbox is running. (PID $PID)"
                          exit 1
        fi
         HOME=$(/sbin/getcfg $QPKG_NAME Install_Path -d "" -f $CONF) 
         [ -d $HOMEDIR ] || /bin/mkdir -p $HOMEDIR
#create symbolic links                                    
         [ -d $HOMEDIR/.dropbox ] || ln -sf $HOME/.dropbox $HOMEDIR/.dropbox
         [ -d $HOMEDIR/Dropbox ] || ln -sf $HOME/Dropbox $HOMEDIR/Dropbox
         [ -d /root/.dropbox-dist ] || ln -sf $HOME/.dropbox-dist /root/.dropbox-dist
         [ -d /root/.dropbox ] || ln -sf $HOME/.dropbox /root/.dropbox
         echo 100000 > /proc/sys/fs/inotify/max_user_watches
         OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
         LD_LIBRARY_PATH=$HOME:$LD_LIBRARY_PATH
         export LANG=$LOCALE
         $HOME/$DAEMON > $HOME/Dropbox_status.txt 2>&1 &
         RETVAL=$?
         /bin/sleep 5
         ;;
  stop) 
    PID=`ps -ef | awk '/[d]ropbox/{print $1}'`
         if [ -z $PID ] ; then
        /bin/echo "Dropbox isn't running!"
        exit 1
         fi
         kill -9 $PID
         echo "Dropbox daemon stopped."
         RETVAL=$?
         sleep 3
         ;;
  restart)
         sh $0 stop
         sh $0 start
         RETVAL=$?
         ;;
  status)
    PID=`ps -ef | awk '/[d]ropbox/{print $1}'`
    if [ -z $PID ] ; then
        echo "Dropbox isn't running!"
    else
        echo "Dropbox is running. (PID $PID)"
    fi
         ;;
  *)
         /bin/echo "Usage: $0 {start|stop|restart|status}"
         exit 1
esac

exit $RETVAL
§  Set the execute bit:
# chmod +x /share/MD0_DATA/.qpkg/Dropbox/Dropbox.sh
§  Reboot
References: