Import files to seafile from cli

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8756C4F765C9AC3CB6B85D62379CE192D401AB61
echo deb http://dl.bintray.com/seafile-org/deb jessie main | sudo tee /etc/apt/sources.list.d/seafile.list
sudo apt-get update
apt-get install seafile-cli

Now setup cli:
# choose a folder where to store the seafile client settings e.g ~/seafile-client

mkdir ~/seafile-client            # create the settings folder
seaf-cli init -d ~/seafile-client  # initialise seafile client with this folder
seaf-cli start
seaf-cli is command line interface for seafile client.
Subcommands:
    init:           create config files for seafile client
    start:          start and run seafile client as daemon
    stop:           stop seafile client
    list:           list local liraries
    status:         show syncing status
    download:       download a library from seafile server
    sync:           synchronize an existing folder with a library in
                        seafile server
    desync:         desynchronize a library with seafile server
    create:         create a new library
Detail
======
Seafile client stores all its configure information in a config dir. The default location is `~/.ccnet`. All the commands below accept an option `-c <config-dir>`.
init
----
Initialize seafile client. This command initializes the config dir. It also creates sub-directories `seafile-data` and `seafile` under `parent-dir`. `seafile-data` is used to store internal data, while `seafile` is used as the default location put downloaded libraries.
    seaf-cli init [-c <config-dir>] -d <parent-dir>
start
-----
Start seafile client. This command start `ccnet` and `seaf-daemon`, `ccnet` is the network part of seafile client, `seaf-daemon` manages the files.
    seaf-cli start [-c <config-dir>]
stop
----
Stop seafile client.
    seaf-cli stop [-c <config-dir>]
Download
--------
Download a library from seafile server
    seaf-cli download -l <library-id> -s <seahub-server-url> -d <parent-directory> -u <username> -p <password>
sync
----
Synchronize a library with an existing folder.
    seaf-cli sync -l <library-id> -s <seahub-server-url> -d <existing-folder> -u <username> -p <password>

First retrieve the library id by browsing on the server -> it's in the url after "/repo/"

usage: seaf-cli sync [-h] [-c CONFDIR] [-l LIBRARY] [-s SERVER] [-u USERNAME]
                     [-p PASSWORD] [-d FOLDER]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFDIR, --confdir CONFDIR
                        the config directory
  -l LIBRARY, --library LIBRARY
                        library id
  -s SERVER, --server SERVER
                        URL for seafile server
  -u USERNAME, --username USERNAME
                        username
  -p PASSWORD, --password PASSWORD
                        password
  -d FOLDER, --folder FOLDER
                        the existing local folder


desync
------
Desynchronize a library from seafile server
    seaf-cli desync -d <existing-folder>
create
------
Create a new library
    seaf-cli create -s <seahub-server-url> -n <library-name> -u <username> -p <password> -t <description> [-e <library-password>]
'''

Get library id:

seaf-cli list-remote -s  "https://cloud.joel.co.in" -u "[email protected]" -p "mypassword"
Name    ID
My Library d9d122233-43b6-4af3-21dde-59aawwwww45df11

Now download to local folder:

seaf-cli download -l "d9d122233-43b6-4af3-21dde-59aawwwww45df1" -s  "https://cloud.joel.co.in" -d /tmp/lib -u "[email protected]" -p "mypassword"
Starting to download ...
Library d9d122233-43b6-4af3-21dde-59aawwwww45df1 will be downloaded to /tmp/lib

Now add to this directory:

cp /tmp/att/* /tmp/lib/My\ Library/Shanghumukham-April\ 2017/Arun/

You dont need to upload/sync after adding files. The daemon automatically does that. In fact, if you attempt to sync you get an error:

seaf-cli sync -l "d9d122233-43b6-4af3-21dde-59aawwwww45df1" -s  "https://cloud.joel.co.in" -d /tmp/lib -u "[email protected]" -p "mypassword"
Starting to download ...
Traceback (most recent call last):
  File "/usr/bin/seaf-cli", line 832, in <module>
    main()
  File "/usr/bin/seaf-cli", line 828, in main
    args.func(args)
  File "/usr/bin/seaf-cli", line 568, in seaf_sync
    email, random_key, enc_version, more_info)
  File "/usr/lib/python2.7/dist-packages/pysearpc/client.py", line 112, in newfunc
    return fret(ret_str)
  File "/usr/lib/python2.7/dist-packages/pysearpc/client.py", line 25, in _fret_string
    raise SearpcError(dicts['err_msg'])
pysearpc.common.SearpcError: Repo already exists

It may be a good option to desync at the end lest you end up deleting needed folders/files.

Stopping sync:

seaf-cli desync -d /tmp/lib/My\ Library

Syncing to existing local library after desyncing:

seaf-cli sync -l "d9d122233-43b6-4af3-21dde-59aawwwww45df1" -d /root/SeafileLocalSync -s  "https://cloud.joel.co.in" -u "[email protected]"

More information from the Wiki:

Seafile client for a Cli server
Installation
You can follow this documentaion to install Seafile CLI client on various Linux distributions.

Basic Usage
Initialise & start the client

# choose a folder where to store the seafile client settings e.g ~/seafile-client
mkdir ~/seafile-client            # create the settings folder
seaf-cli init -d ~/seafile-client  # initialise seafile client with this folder
seaf-cli start
Download a library from a server

retrieve the library id by browsing on the server -> it's in the url after /repo/
then
seaf-cli download -l "the id of the library" -s  "the url + port of server" -d "the folder where the library folder will be downloaded" -u "username on server" [-p "password"]
seaf-cli status  # check status of ongoing downloads
# Name  Status  Progress
# Apps    downloading     9984/10367, 9216.1KB/s
Note: if you not supply the password parameter in the command, it will be asked later, which is more safe.

Example: `seaf-cli download -l 0536c006-8a43-449e-8718-39f12111620d -s http://cloud.seafile.com -d /tmp -u [email protected]`
Download a library from a server and sync with an existing folder.

# This is the same as download : replace download by sync 
seaf-cli sync -l "the id of the library" -s  "the url + port of server" -d "the folder where the library will be synced with" -u "username on server" -p "password"
Man documentation
seaf-cli is command line interface for seafile client.

Subcommands:

init                Initialize config directory
start               Start ccnet and seafile daemon
stop                Stop ccnet and seafile daemon
list                List local libraries
list-remote         List remote libraries
status              Show syncing status
download            Download a library from seafile server
download-by-name    Download a library defined by name from seafile server
sync                Sync a library with an existing foler
desync              Desync a library with seafile server
create              Create a library
config              Configure seafile client
Running seaf-cli -h will show the above help. For each subcommand, you can also use -h option to get help, e.g. seaf-cli download -h.

Detail
Seafile client stores all its configure information in a config dir. The default location is ~/.ccnet. All the commands below accept an option -c <config-dir>.

init
Initialize seafile client. This command initializes the config dir. It also creates sub-directories seafile-data and seafile under parent-dir. seafile-data is used to store internal data, while seafile is used as the default location put downloaded libraries.

seaf-cli init [-c <config-dir>] -d <parent-dir>
A file named seafile.ini will be created under ~/.ccnet to record the location of seafile-data directory.

If you want to run multiple instances of Seafile cli client in the same machine, you can specify different config-dir and parent-dir when initializing different client instances. Then the instances can run without interfering each others. When starting the instances, just specify ccnet config directories with the -c option.

start
Start seafile client. This command start ccnet and seaf-daemon, ccnet is the network part of seafile client, seaf-daemon manages the files.

seaf-cli start [-c <config-dir>]
stop
Stop seafile client.

seaf-cli stop [-c <config-dir>]
Download
Download a library from seafile server

seaf-cli download -l <library-id> -s <seahub-server-url> -d <parent-directory> -u <username> [-p <password>]
sync
Synchronize a library with an existing folder.

seaf-cli sync -l <library-id> -s <seahub-server-url> -d <existing-folder> -u <username> [-p <password>]
desync
Desynchronize a library from seafile server

seaf-cli desync -d <existing-folder>
create
Create a new library on server

seaf-cli create [-h] -n library-name -t description [-e library-password] -s server -u username -p password
Skip SSL certificate verify
If you're using self-signed certificate on the server, you should ask the client to skip verifying certificate.

seaf-cli config -k disable_verify_certificate -v true
Set Transfer Speed Limit
Set upload speed limit to 1MB/s :

seaf-cli config -k upload_limit -v 1000000
Set download speed limit to 1MB/s :

seaf-cli config -k download_limit -v 1000000

To sync your Dropbox folder to a new library in Seafile, create a library in Seafile named Dropbox. Then install Dropbox headless on the server and start the daemon:

64-bit:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Next, run the Dropbox daemon from the newly created .dropbox-dist folder. You will need to authorize after starting the daemon:

~/.dropbox-dist/dropboxd
Dowload the Dropbox helper python script if you want fine grained control:
wget https://www.dropbox.com/download?dl=packages/dropbox.py
mv download\?dl\=packages%2Fdropbox.py dropbox.py
chmod +x dropbox.py
./dropbox.py

Now create a library in Seafile, note its library id (the sequence after /lib/)
Make seafile sync to existing Drobox directory

seaf-cli sync -l [libid] -s "https://cloud.yoursom.com" -u [Username] -d ~/Dropbox

To sync Google Drive:
First install the cli:
apt-get install git cmake build-essential libgcrypt11-dev libyajl-dev \
libboost-all-dev libcurl4-openssl-dev libexpat1-dev libcppunit-dev binutils-dev
git clone https://github.com/Grive/grive.git
cd grive
dpkg-buildpackage -j4 -uc -us
dpkg -i ../grive*deb
mkdir ~/GoogleDrive
cd ~/GoogleDrive
grive -a
seaf-cli sync -l [libid] -s “https://cloud.yoursom.com” -u [Username] -d ~/GoogleDrive
grive &
[/bash]

grive doesnt run as a daemon, so create a cron job to sync files every 5 minutes:

*/5 * * * * cd /root/GoogleDrive && /usr/bin/grive

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Install and use tightvnc viewer on Ubuntu

We’ll assume that you have a server running tightvnc server. If you dont, search this site for tutorials on the same.

Now, on the client PC, install xtightvncviewer to connect to the server:

sudo apt-get install xtightvncviewer

Connect with:

xtightvncviewer 3.45.212.2::5901

here, 3.45.212.2 is the ip of the server, and 5901 is the port (default tightvnc server port).


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to setup Calibre Library web server on your Debian VPS

Calibre is a popular Ebook library software to backup,restore, and organize digital prints of books (popularly called e-books). It works with many devices including Amazon Kindle, Kindle for PC software, Nook etc. A lesser known software is Calibre server which allows you to share non copyright-protected content over the internet.

The following instructions summarize how to setup Calibre library server on your Debian or Ubuntu VPS:

Login as webserver user via ssh.

Enter the following commands:

sudo -v wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
sudo apt-get update
sudo apt-get install xvfb imagemagick
mkdir ~/calibre-library
mkdir ~/calibre-library/toadd
nohup calibre-server --with-library ~/calibre-library 

Now, you will be able to access your Library at http://yourip:8080

If you need to change the default port, run this:

calibre-server --with-library ~/calibre-library --port 8180

Adding books to the library:

Copy/Upload your files to ~/calibre-library/toadd and then run:

xvfb-run calibredb add ~/calibre-library/toadd/* --library-path ~/calibre-library

Of course you can create aliases/scripts for any of these commands to automate.

References:

  1. DigitalOcean

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Change utorrent server (utserver) web port

So utserver and i-mscp decided to use the same webport – 8080. I changed utserver’s port.

Go to the directory containing utserver and delete existing settings.dat

rm settings.dat*

Create file utserver.conf containing:

ut_webui_port: 8085

Restart utserver using new settings:

./utserver -settingspath /home/utorrent -configfile /home/utorrent/utserver.conf -logfile /home/utorrent/utserver.log -daemon

Now browse to:

http://myip:8085/gui/web/index.html

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Setting up OpenVZ and the OpenVZ Web panel on Debian

First, you’d need to install Debian on your server. For DelimiterVPS, go to https://clients.delimitervps.com/clientarea.php, and login to your account.
Choose the Reinstall server option.
Under ‘Installation Profile’, choose ‘Debian Wheezy’.
Choose a good enough root password. From personal experience, I’d avoid special characters in my root password. I had setup a very complex password once, and found that it was not accepted by the ssh login shell. It’s likely that WHMCS does not escape special characters very well.
Choose ‘Provision Server (Warning)’.

At this point, go back to the email you received from DelimiterVPS, and read the part about KVM/ILO Configuration. You can login to ILO and watch the installation progress. Once installation is done, Proxmox is supposed to be up and running at https://yourip::8006. However we need a couple of steps and a reboot before we can use it.

Run the following:

cat << EOF > /etc/apt/sources.list.d/openvz-rhel6.list
deb http://download.openvz.org/debian wheezy main
EOF
wget http://ftp.openvz.org/debian/archive.key
apt-key add archive.key
apt-get update

Install OpenVZ kernel:

apt-get install linux-image-openvz-amd64

First, you have to remove the default Linux kernel, and set the OpenVZ kernel to start at boot.
Run the following from the shell:

apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64 linux-base
update-grub

You’ll notice that openvz based kernels have now been added to grub (the bootloader).

Enable IP forwarding and other rules are setup:
Edit the file /etc/sysctl.conf, and uncomment/add (Remove the # at the beginning) the following lines:

# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# Enables the magic-sysrq key
kernel.sysrq = 1

# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

run the following:

sysctl -p
apt-get install vzctl vzquota ploop vzstats

Now, restart the server.

reboot

Run the following:

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

After some time the installation may stop with the following message:
Fatal error: Panel requires Ruby 1.8 (Ruby 1.9 is not supported).

Run:

update-alternatives --config ruby
# update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.9.1   51        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   51        manual mode

Press enter to keep the current choice[*], or type selection number: 1

Now rerun the installation:

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

At the end, you will get the message:

Panel should be available at:
http://x.droidzone.in:3000
Default credentials: admin/admin

Now login, and change the default password.

You can now install OpenVZ templates(Physical servers>Localhost>OS Templates>Install new OS Template).
Assign ips to the pool (Ip Addresses>Create new IP pool). Add the IPs assigned to you. You may need to buy more from your provider.

To create a VPS:
Localhost>Virtual servers list>Create virtual server

Creating a custom template.
Provision a VPS using a default template.
Login to the VPS, setup everything including resolvconf, tzdata, locales, dialog, .bashrc etc.

vzctl stop 1
vzctl set 1 --ipdel all --save
cd /var/lib/vz/private/1
tar --numeric-owner -czf /var/lib/vz/template/cache/debian-7.0-x86_64-minimal-custom.tar.gz .

Change default port and enable SSL on Openvz web panel:
Change the following in /etc/owp.conf:

# web server port
PORT=3000

to

PORT=2096

and

# SSL support, on - enable, off - disable
SSL=off

to

SSL=on

Restart the service. Now it is accessible at https://yourdomain.com:2096

I chose 2096 because it is one of the ports that Cloudflare supports and thus you get a free SSL support with Cloudflare.

Create a symlink to /vz because most of the vz tools expects the OpenVZ folders to reside there. This step is not necessary, but can eliminate further problems when other vz related components are installed.

ln -s /var/lib/vz /vz

You also probably need to change:

#NEIGHBOUR_DEVS="detect"

to

NEIGHBOUR_DEVS="all"

at /etc/vz/vz.conf

and do a

service vz restart

For Reference, my network config on node is as below:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 157.266.186.60
        netmask 255.255.255.192
        network 157.266.186.0
        broadcast 157.266.186.63
        gateway 157.266.186.62
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search droidzone.in

And my two addon ips are:

157.266.187.162/32
157.266.187.163/32

Obviously the ips have been scrambled.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Setting up Virtual private servers via Proxmox on a ‘DelimiterVPS’ dedicated server

DelimiterVPS had a nice offer for a value-for-money Dedicated server, the other day. I pounced on my chance to add another dedicated server to my collection. The other one is an Online.net Euro 5.99 server that I have been using for the past year. The server provisioning was quick (within two hours of payment). I paid via Paypal.

Now about setting up the server for creating VPSes..

First, go to https://clients.delimitervps.com/clientarea.php, and login to your account.
Choose the Reinstall server option.
Under ‘Installation Profile’, choose ‘Proxmox VE 3.0’.
Choose a good enough root password. From personal experience, I’d avoid special characters in my root password. I had setup a very complex password once, and found that it was not accepted by the ssh login shell. It’s likely that WHMCS does not escape special characters very well.
Choose ‘Provision Server (Warning)’.

At this point, go back to the email you received from DelimiterVPS, and read the part about KVM/ILO Configuration. You can login to ILO and watch the installation progress. Once installation is done, Proxmox is supposed to be up and running at https://yourip::8006. However we need a couple of steps and a reboot before we can use it.

First, you have to remove the default Linux kernel, and set the OpenVZ kernel to start at boot.
Run the following from the shell:

apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64 linux-base
update-grub

You’ll notice that openvz based kernels have now been added to grub (the bootloader).

If you’d prefer a login screen with Cloudflare SSL, you’d want to change the default Proxmox web panel port from 8006 to 2053, 2083, 2087, 2096, or 8443. (See https://support.cloudflare.com/hc/en-us/articles/200169156-Which-ports-will-CloudFlare-work-with-)

Do this:

sed -i 's/port => 8006/port => 2096/' /usr/bin/pveproxy
service pveproxy restart

Enable IP forwarding is setup:
Edit the file /etc/sysctl.conf, and uncomment (Remove the # at the beginning) the following line:

#net.ipv4.ip_forward=1

You can just run the following:

sed -i "s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g" /etc/sysctl.conf
sysctl -p

Now, restart the server.

You can now login to Proxmox at:

https://yourdomainname.com:2096 (If you changed the IP for Cloudflare DNS),

or

https://yourip:8006 (Default Proxmox login URL).

Choose your server’s root password with Linux PAM authentication.

Before creating VPSes, you need to download OpenVZ templates to the server.
Click on server, and ‘local(server)’ under ‘server’.
Click on the tab ‘Content’
Click on Templates,
Under Section:system, choose to download templates you require.

Now to create a new VPS, Click on ‘Create CT’, enter the following:
Node and VM ID should be automatically populated.
Enter hostname for your VPS: test1.mydomain.com
Password: Choose a complex password
Confirm Password.

Click on Next.
Choose a template from the dropdown.
Click on Next.
Now, choose values for Memory, Swap, Disk size, CPU.
Click on Next.
Choose routed mode, enter one of the ‘additional ip addresses’ you purchased from DelimiterVPS.
Click on Next.
Click on Next again.
Click on Finish.

Your virtual server is now ready. Try logging to it via ssh.

To remove the Proxmox ‘You do not have a valid subscription nag popup’, run the following:

cp /usr/share/pve-manager/ext4/pvemanagerlib.js /usr/share/pve-manager/ext4/pvemanagerlib.bak.js
sed -i "s/data.status !== 'Active'/false/" /usr/share/pve-manager/ext4/pvemanagerlib.js

Credits:
MarkTurner at Lowendtalk for help with server settings


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to setup a self hosted Seafile for your server.

We’ll assume that you have a freshly installed Digitalocean server, and have logged into it via ssh:

alias l='ls -lah --color'
apt-get update && apt-get install emacs
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
AllowUsers haiwen
service ssh restart
useradd haiwen -s /bin/bash -m
adduser haiwen sudo
usermod -a -G www-data haiwen
passwd haiwen
apt-get install sudo
sed -i 's/main/main contrib non-free/g' /etc/apt/sources.list
apt-get update
locale-gen en_US.UTF-8

Now connect as user haiwen to ssh:

wget https://bitbucket.org/haiwen/seafile/downloads/seafile-server_4.1.2_x86-64.tar.gz
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
cd seafile-server-4.1.2/
sudo apt-get install python2.7 python-setuptools python-imaging python-mysqldb mysql-server

Run setup-seafile-mysql.sh

[email protected]:~/seafile-server-4.1.2$ ./setup-seafile-mysql.sh
Checking python on this machine ...
  Checking python module: setuptools ... Done.
  Checking python module: python-imaging ... Done.
  Checking python module: python-mysqldb ... Done.
-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at
        https://github.com/haiwen/seafile/wiki
Press ENTER to continue
-----------------------------------------------------------------
What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] acloud.dzon.in

acloud.dzon.in is not a valid name

What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] DroidzoneCloud

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 42.34.117.163

Which port do you want to use for the ccnet server?
[ default "10001" ]

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/home/haiwen/seafile-data" ]

Which port do you want to use for the seafile server?
[ default "12001" ]

Which port do you want to use for the seafile fileserver?
[ default "8082" ]

-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 1

What is the host of mysql server?
[ default "localhost" ]

What is the port of mysql server?
[ default "3306" ]

What is the password of the mysql root user?
[ root password ]

verifying password of user root ...
Failed to connect to mysql server using user "root" and password "***": Can't connect to MySQL server on '127.0.0.1' (111)

What is the password of the mysql root user?
[ root password ]

verifying password of user root ...  done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "root" ] seafilusr

Enter the password for mysql user "seafilusr":
[ password for seafilusr ]

Enter the database name for ccnet-server:
[ default "ccnet-db" ]

Enter the database name for seafile-server:
[ default "seafile-db" ]

Enter the database name for seahub:
[ default "seahub-db" ]

---------------------------------
This is your configuration
---------------------------------

    server name:            DroidzoneCloud
    server ip/domain:       42.34.117.163
    ccnet port:             10001

    seafile data dir:       /home/haiwen/seafile-data
    seafile port:           12001
    fileserver port:        8082

    database:               create new
    ccnet database:         ccnet-db
    seafile database:       seafile-db
    seahub database:        seahub-db
    database user:          seafilusr
---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------
Generating ccnet configuration ...
done
Successly create configuration dir /home/haiwen/ccnet.
Generating seafile configuration ...

Done.
done
Generating seahub configuration ...
----------------------------------------
Now creating seahub database tables ...
----------------------------------------
creating seafile-server-latest symbolic link ...  done
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }

-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------

port of ccnet server:         10001
port of seafile server:       12001
port of seafile fileserver:   8082
port of seahub:               8000

When problems occur, Refer to

        https://github.com/haiwen/seafile/wiki

for information.

[email protected]:~/seafile-server-4.1.2$ ulimit -n 30000
[email protected]:~/seafile-server-4.1.2$ ./seafile.sh start

Starting seafile server, please wait ...
Seafile server started

Done.
[email protected]:~/seafile-server-4.1.2$ ./seahub.sh start

Starting seahub at port 8000 ...

----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------

What is the email for the admin account?
[ admin email ] [email protected]

What is the password for the admin account?
[ admin password ]

Enter the password again:
[ admin password again ]



----------------------------------------
Successfully created seafile admin
----------------------------------------



Loading ccnet config from /home/haiwen/ccnet
Loading seafile config from /home/haiwen/seafile-data

Seahub is started

Done.

Now seafile is accessible at http://45.55.195.173:8000/

Next up, setting https for seafile.

To start Seafile at Boot:

[email protected]:~$ sudo emacs /etc/init.d/seafile-server
#!/bin/bash

# Change the value of "user" to your linux user name
user=haiwen

# Change the value of "seafile_dir" to your path of seafile installation
# usually the home directory of $user
seafile_dir=/home/haiwen
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=false
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000
#
# Write a polite log message with date and time
#
echo -e "\n \n About to perform $1 for seafile at `date -Iseconds` \n " >> ${seafile_init_log}
echo -e "\n \n About to perform $1 for seahub at `date -Iseconds` \n " >> ${seahub_init_log}
case "$1" in
        start)
                sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
                if [ $fastcgi = true ];
                then
                        sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi ${fastcgi_port} >> ${seahub_init_log}
                else
                        sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
                fi
        ;;
        restart)
                sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
                if [ $fastcgi = true ];
                then
                        sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi ${fastcgi_port} >> ${seahub_init_log}
                else
                        sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
                fi
        ;;
        stop)
                sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
        ;;
        *)
                echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
                exit 1
        ;;
esac
sudo emacs /etc/init/seafile-server.conf
start on (started mysql
and runlevel [2345])
stop on (runlevel [016])

pre-start script
/etc/init.d/seafile-server start
end script

post-stop script
/etc/init.d/seafile-server stop
end script
[email protected]:~$ sudo chmod +x /etc/init.d/seafile-server
[email protected]:~$ sudo update-rc.d seafile-server defaults

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Specifying a different ssh port while doing rsync

Use rsync with the -e option to specify the port:

rsync -avr -e 'ssh -p 9992' files/ [email protected]:/var/www/

Here, you specify the port with rsync -e 'ssh -p PORT'


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Create a new user for vncserver

Install vnc:

apt-get install tightvncserver xtightvncviewer

Create a new user:

useradd -c "Tightvnc user" -m -r -s /bin/bash vncuser
sudo -iu vncuser bash
unset XAUTHORITY
vncserver

Create the password and you are done.

Reference:

Note that 5901 is the default port.

Now, everytime you do:

sudo -iu vncuser bash

,
vnc server will start as that user. You should never run it as root.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Change default ssh port from 22 on Debian and Ubuntu

Often it is noted that automated brute force ports tend to attack servers with ssh service on port 22. Of course it is not difficult to scan a port range and determine whether you have ssh running on another port, but usually that happens only in targeted or more sophisticated ports.

So one of the ways you can improve the security of your server is to change the default ssh port from port 22.

Edit /etc/ssh/sshd_config:

Change:

#grep -i port  /etc/ssh/sshd_config
# What ports, IPs and protocols we listen for
Port 22

to

#grep -i port  /etc/ssh/sshd_config
# What ports, IPs and protocols we listen for
Port 959

Restart ssh later:

#service ssh restart
[ ok ] Restarting OpenBSD Secure Shell server: sshd.

Once you do this, commands like ssh-copy-id will not work unless you write it as:

ssh-copy-id -i key "[email protected] -p NewPort"

or specify port in ~/.ssh/config with:

Host iniz
Hostname hostip
User root
Port newport


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.