Monday, November 06, 2017

Setting Up Syncthink by Command Line on a Server

Props to this site for the info I based the following on!

First, install syncthing:

$ sudo apt-get update 

$ sudo apt-get install syncthing

$ syncthing


You will need to change the address of the web gui by editing the syncthing config.xml.

$ sudo nano ~/.config/syncthing/config.xml 

<gui enabled="true" tls="false">
<address>127.0.0.0:8384</address>

[to]:

<gui enabled="true" tls="false">
<address>192.168.1.119:8384</address>

systemd is a system and service manager for Linux that runs as PID 1 (Process ID 1) and starts the rest of the system. It uses a script file called a Unit for each service, they are located in /etc/systemd/system/multi-user.target.wants/ to get this to work you need to put this file into that directory.


This is the Unit text
***********************************************************************
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=http://docs.syncthing.net/
After=network.target
Wants=syncthing-inotify@.service
[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=multi-user.target
***********************************************************************
Copy this file into the etc/systemd/system/multi-user.target.wants directory and name it with the service username you login as:

$ sudo systemctl enable syncthing@username.service
$ sudo systemctl start syncthing@username.service


That's it, reboot your server to check syncthing starts and then you can start setting up the folders you want to sync from the webgui.
 

Saturday, November 04, 2017

Samba Setup


Installation and Setup:

First install the following:

apt-get install samba-common smbclient samba-common-bin smbclient cifs-utils

Next, authorize users to access samba shares:

sudo smbpasswd -a

Make a safe backup copy of the original smb.conf file.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bkup

Edit the file "/etc/samba/smb.conf"

sudo nano /etc/samba/smb.conf

Add this to the end of the file:

[folder_name]
path = /home/user_name>/folder_name
valid users =
read only = no

Restart samba:

sudo service smbd restart

Use this command to check your smb.conf for any syntax errors.

testparm

Determine the LAN address of the computer:

sudo ifconfig

List all shares:

smbclient -L /// -U

Connect:

smbclient /// -U

Mounting Local Shares:

smbclient -L XXX.XXX.X.X -U username

Then, create a local directory and mount the remote share:

mkdir /mnt/abc mount -t cifs //server/share /mnt/abc

Depending on the access you give to your windows share are the credentials required: if you give your share 'Everyone' read (and write) access nothing else is required, otherwise you must add credentials at mount time:

mount -t cifs //server/share /mnt/abc -o user=user,pass=password,dom=domain

When finished just dismount the share:

umount /mnt/abc

Sunday, October 22, 2017

Testing Moodle on Debian 9

So I bought a Raspberry Pie and put Debian 9 on it so that I can play around with it as a home server. Currently I am configuring Moodle on it, so here are my notes:

Debian 9 (stretch) has 2.7.17 in the repositories. This is fairly old, so I will be installing the git version instead.

First:

sudo apt-get update

Second:

sudo apt-get install apache2 mysql-client mysql-server php7.0 libapache2-mod-php7.0

Third:

sudo apt-get install graphviz aspell php7.0-pspell php7.0-curl php7.0-gd php7.0-intl php7.0-mysql php7.0-xml php7.0-xmlrpc php7.0-ldap php7.0-zip php7.0-soap php7.0-mbstring


Forth:

sudo service apache2 restart

Fifth:

sudo apt-get install git-core

Sixth:

cd /opt

Seventh:

sudo git clone git://git.moodle.org/moodle.git

Eighth:

cd moodle

Ninth:

sudo git branch -a

Since the guide I'm following is installing Moodle 3.1, and I don't want any incompatibilities, this is what I will be installing as well.


10th:

sudo git branch --track MOODLE_31_STABLE origin/MOODLE_31_STABLE

11th:

sudo git checkout MOODLE_31_STABLE

12th:

sudo cp -R /opt/moodle /var/www/html/

13th:

sudo mkdir /var/moodledata

14th:

sudo chown -R www-data /var/moodledata

15th:

sudo chmod -R 777 /var/moodledata

16th:

sudo chmod -R 0755 /var/www/html/moodle

17th:

sudo mysql -u root -p

18th:

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

19th:

create user 'username'@'localhost' IDENTIFIED BY 'passwordforuser';

NOTE: Make sure to change 'username' 'passwordforuser' to whatever password you would like. (to change the password, you can used the following command: set password for moodle@localhost = password('newpassword');)

20th:

MariaDB [(none)]> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodle@localhost IDENTIFIED BY 'password';

NOTE: Again, adjust username and password.

21st:

MariaDB [(none)]> quit;

22nd:

sudo chmod -R 777 /var/www/html/moodle

23rd:

sudo chmod -R 0755 /var/www/html/moodle

24th:

Open your browser and go to http://IP.ADDRESS.OF.SERVER/moodle
Follow the prompts:

Change the path for moodledata: /var/moodledata

Host server: localhost
Database: moodle
User: username (the user you created when setting up the database)
Password: userpassword (the password for the user you created)
Tables Prefix: mdl_

25th:

sudo chmod -R 0755 /var/www/html/moodle









Saturday, October 14, 2017

Setting Up Mopidy, Ncmpcpp, and Spotify on Debian Stretch

As of Debian Stretch, there are a few things to do. Here is the breakdown

Add the archive’s GPG key: 

wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - 

Add the APT repo to your package sources: 

sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/stretch.list 

Install Mopidy and all dependencies: 
 
sudo apt-get update
sudo apt-get install mopidy mopidy-spotify ncmpcpp


There are two configuration files that need to be adjusted. 

First, there is the Mopidy configuration file: ~/.config/mopidy/mopidy.conf

Here is my configuration file:

# For further information about options in this file see:
#   http://docs.mopidy.com/
#
# The initial commented out values reflect the defaults as of:
#   Mopidy 2.1.0
#   Mopidy-File 2.1.0
#   Mopidy-HTTP 2.1.0
#   Mopidy-Local 2.1.0
#   Mopidy-M3U 2.1.0
#   Mopidy-MPD 2.1.0
#   Mopidy-SoftwareMixer 2.1.0
#   Mopidy-Spotify 3.1.0
#   Mopidy-Stream 2.1.0
#
# Available options and defaults might have changed since then,
# run `mopidy config` to see the current effective config and
# `mopidy --version` to check the current version.

[core]
#cache_dir = $XDG_CACHE_DIR/mopidy
#config_dir = $XDG_CONFIG_DIR/mopidy
#data_dir = $XDG_DATA_DIR/mopidy
#max_tracklist_length = 10000
#restore_state = false

[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
debug_file = /.config/mopidy/mopidy.log

[audio]
output = tee name=t t. ! queue ! autoaudiosink t. ! queue ! audioresample ! audioconvert ! audio/x-raw,rate=44100,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/mpd.fifo
#mixer = software
#mixer_volume =
#output = autoaudiosink
#buffer_time =

[proxy]
#scheme =
#hostname =
#port =
#username =
#password =

[mpd]
enabled = true
hostname = 127.0.0.1
port = 6600
#password =
#max_connections = 20
#connection_timeout = 60
#zeroconf = Mopidy MPD server on $hostname
#command_blacklist =
#  listall
#  listallinfo
#default_playlist_scheme = m3u

[http]
#enabled = true
#hostname = 127.0.0.1
#port = 6680
#static_dir =
#zeroconf = Mopidy HTTP server on $hostname

[stream]
#enabled = true
#protocols =
#  http
#  https
#  mms
#  rtmp
#  rtmps
#  rtsp
#metadata_blacklist =
#timeout = 5000

[m3u]
#enabled = true
#base_dir = $XDG_MUSIC_DIR
#default_encoding = latin-1
#default_extension = .m3u8
#playlists_dir =

[softwaremixer]
#enabled = true

[file]
#enabled = true
#media_dirs =
#  $XDG_MUSIC_DIR|Music
#  ~/|Home
#excluded_file_extensions =
#  .jpg
#  .jpeg
#show_dotfiles = false
#follow_symlinks = false
#metadata_timeout = 1000

[local]
#enabled = true
#library = json
#media_dir = $XDG_MUSIC_DIR
#scan_timeout = 1000
#scan_flush_threshold = 100
#scan_follow_symlinks = false
#excluded_file_extensions =
#  .directory
#  .html
#  .jpeg
#  .jpg
#  .log
#  .nfo
#  .png
#  .txt

[spotify]
enabled = true
username =
password =
client_id =
client_secret =
#bitrate = 160
#volume_normalization = true
#private_session = false
#timeout = 10
#allow_cache = true
allow_network = true
allow_playlists = true
#search_album_count = 20
#search_artist_count = 10
#search_track_count = 50
#toplist_countries =


You put your username and password, above as requested under the Spotify section. Then you need to now go to https://www.mopidy.com/authenticate/ to get your client_id and client_secret.

Finally, you need to edit (or create) the following ncmpcpp configuration file in order for visualizations to work ~/.ncmpcpp/config

Here is what I have in mine:

visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "30"
visualizer_in_stereo = "yes"
visualizer_type = "spectrum"
visualizer_look = "+|"


Most Used Shortcut Keys for Ncmpcpp

  • 1 - Current playlist
  • 2 - Filesystem browser
  • 3 - DB search
  • 4 - Library
  • 5 - Playlist editor
  • 6 - Tag editor
  • 7 - Output selector
  • 8 - Music visualizer
  • = - Clock
  • F1 - Help

Other UI keys

  • q - Quit
  • f - Seek forward
  • b - Seek backward
  • \ - Switch between classic and alternative views
  • i - Show song info
  • I - Show artist info (saved in ~/.ncmpcpp/artists/ARTIST.txt)
  • L - Shuffle between available lyric databases
  • l - Retrieve song lyrics for current song Show/hide lyrics
  • > - Next track
  • < - Previous track
  • p - Play/Pause
  • a - Add item to playlist
  • S - Save playlist
  • c - Clear playlist
  • r - Toggle repeat mode
  • z - Toggle random mode
  • + - Increase volume 2%
  • - - Decrease volume 2%

Additional Backend Extensions - WORK IN PROGRESS:


spotify-tunigo - "Spotify Browse" is provided by the Mopidy-Spotify-Tunigo extension. It allows you to browse certain playlists on Spotify. First, install it: sudo apt-get install mopidy-spotify-tunigo Then modify ~.config/mopidy/mopidy.conf by adding the following lines:

[spotify-tunigo] 

enabled = true

mopidy-scrobbler -
sudo apt-get install mopidy-spotify-tunigo

[scrobbler]
enabled = true
username = your_username
password = your_password

mopidy-soundclound - sudo apt-get install mopidy-soundcloud

[soundcloud]
enabled = true
explore_songs = 25
auth_token =[go to https://www.mopidy.com/authenticate/ to get it]

mopidy-youtube - I had trouble getting this one to work using the repositories. I had to use 'pip' instead:


sudo apt-get install python-pip [if you don't already have it installed]
sudo pip install --upgrade pafy
sudo pip install --upgrade mopidy-youtube 

mopidy-tunein - Install: sudo apt-get install mopidy-tunein  Then modify ~.config/mopidy/mopidy.conf by adding the following lines:

[tunein]
timeout = 5000


mopidy-internetarchive -

mopidy-somafm -
sudo apt-get install mopidy-somafm

That's it!

mopidy-podcast -

Monday, January 09, 2017

booklet creation and imposition in linux

in this post, i will go over how to create "signatures" from pdf files in linux so that you can print them out for your bookbinding projects. these booklets are the result of "imposition" - rearranging pages so that when printed and folded together - produces a series of signatures (booklets) that can then be bound together in books. there does not seem to be very good documentation on how to do this in linux, as far as i can tell.


the sizes

here i will only be focusing on booklets of eight printout pages - meaning that the signatures are 32 pages long (two pages on each side of the paper multiplied by eight), but the same reasoning can be applied to signatures of different sizes.

since the minimal signature is four pages long, the length of signatures need to be in multiples of four. i prefer 32 pages signatures generally (eight pages), but others may prefer shorter signatures. if total book you are printing is 247 pages, and you have 32 page signatures, then you will have eight booklets (the last booklets will have blank pages).

the commands

you will need to install: pdfjam


once installed, here are he commands you can use (depending on the type of duplex printer you have, and in particular, whether it prints things "upside down" on the back of the paper [the first command], or "right-side up" [the second command]). this command will produce a file with '-book' suffixed to the document (example: applied to a "document.pdf" file, this command will produce a new file "document-book.pdf" in the same directory):

$ pdfjam --landscape --suffix book --signature 32 -- document.pdf -


$ pdfjam --landscape --suffix book --signature 32 --preamble '\usepackage{everyshi}
          \makeatletter
          \EveryShipout{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi}
          \makeatother' -- document.pdf -



if anyone knows how to do this with djvu files, i would much appreciate the information!