Saturday, 30 October 2010

Script to start Jdownloader and socks

#!/bin/bash
sh /home/justcop/Sockso/linux.sh --nogui &
jdownloader &

add to /etc/init.d/script.sh

Run scripts at startup

make script at startup

sudo chmod +x /etc/init.d/myscript.sh
sudo update-rc.d myscript.sh defaults

Run programmes which require X over ssh

use ssh -X

Sunday, 17 October 2010

Make samba work

; name resolve order = lmhosts bcast host wins

becomes

name resolve order = lmhosts wins bcast host

in /etc/samba/smb.conf

Saturday, 11 September 2010

Login with alternative user in a different window

Login to a fresh terminal and type

xinit gnome-session -- :2

Backup documents

#! /bin/bash
rsync -r --delete-excluded /home/justcop/Documents /mnt/Storage/Backups/

Then add to cron

Friday, 10 September 2010

backup USB drive on insertion

in autorun on USB pen

#! /bin/bash
rm -r /home/justcop/Documents/"USB backup"
mk dir /home/justcop/Documents/"USB backup"
cp -R /media/"JUSTCOP USB"/Documents /home/justcop/Documents/"USB backup"

Thursday, 15 July 2010

Change ssh port

/etc/ssh/sshd_config

Tuesday, 13 July 2010

My XBMC customisations

sudo apt-get update
sudo apt-get install samba
sudo apt-get install unclutter

sudo apt-get install mysql-server


sudo apt-get install openjdk-6-jre
(for subsonic)

after installing xbmc library updater
cp /home/justcop/.xbmc/addons/script.libraryautoupdate/autoexec.py /home/justcop/.xbmc/userdata/autoexec.py

ls -l /dev/disk/by-uuid
to find id of storage disk

add to /etc/fstab
UUID=6886F8261C1EFA83 /mnt/Storage ntfs defaults 0 1


swap keys for ssh, remember for some reason this allows logging on as just the ip, cannot include the name, can then mount /mnt/Storage using script on desktop PC. See other post.

If xbmc won't load copy in only .xbmc file from home directory


sudo nano /etc/samba/smb.conf

[TV]
comment = TV
path = /mnt/Storage/TV
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes

[Movies]
comment = Movies
path = /mnt/Storage/Movies
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes

[Music]
comment = Music
path = /mnt/Storage/Music
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes

[Photos]
comment = Photos
path = /mnt/Storage/Photos
inherit permissions = yes
read only = No
guest ok = Yes

[Music]
comment = Music
path = /mnt/Storage/Music
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes

[Photos]
comment = Photos
path = /mnt/Storage/Photos
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes

[Downloads]
comment = Downloads
path = /mnt/Storage/Downloads
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes


[Thumbnails]
comment = Thumbnails
path = /home/justcop/.xbmc/userdata/Thumbnails
force user = justcop
inherit permissions = yes
read only = No
guest ok = Yes


name resolve order=lmhosts host wins bcast
bind interfaces only = yes

append /etc/rc.local
echo "USB002" > /proc/acpi/wakeup

sudo mysql

CREATE USER 'justcop' IDENTIFIED BY 'justcop';
CREATE database xbmc_video;
CREATE database xbmc_music;
GRANT ALL ON xbmc_music.* TO 'justcop';
GRANT ALL ON xbmc_video.* TO 'justcop';

ctrl+c

sudo nano /etc/mysql/my.cnf
comment out bind address


(update version)
sudo dpkg -i subsonic*

Creating a button to restart XBMC

After spending many hours on this, XBMC being wiped and starting again at least 3 times without ever remembering what I did last time I think it's finally time to share how I did this so it is written and I never forget.


First we update the sources and download the package which allows running of scripts from a remote button (lirc-x).

sudo apt-get update
sudo apt-get install lirc-x


Next we ensure that this programme (irexec) runs as a daemon (in the background) as soon as we login to gnome by adding it to the .bash_login script


nano .bash_login


add the following code and save

irexec -d

next we make a file contaning the settings for which button and what to with it. I like to use the red button from the MSE remote to do this if you would like to use any other button just change 'red' below to the name of the button you want to choose (for non MSE remotes I have never used the so not sure if this will work, please research elsewhere)

nano .lircrc

add the following code and save

begin
prog = irexec
button = Red
config = ~/restartXBMC.sh
end


We have now said every time the red button is pressed to run the script restartXBMC.sh. Now we have to make this script.

nano restartXBMC.sh

add the following code and save

#!/bin/bash

ps aux|grep -i justcop |grep -v grep|grep -i xbmc.bin|awk '{print $2}'|xargs kill -9

sleep 2

xinit /usr/bin/xbmc
exit


The first line kills XBMC and then waits 2 seconds. The last line starts it back up again

Next we must make the script executable

chmod +x ~/restartXBMC.sh

All done!

Backing up Ubuntu

Ubuntu can be easily backed up using a programme called deja-dup. I recommend configuring deja-dup to backup the /home, /etc and /opt files. /etc should not be restored but it holds a bank of configuration files that may be useful if you need to refer back to them in a fresh setup.

Also create a cron script running daily to backup a list of installed packages using this command


dpkg --get-selections > ~/package.selections


When restoring a backup simply do

sudo dpkg --set-selections ~/package.selections && apt-get dselect-upgrade

after you have readded sources from your sources.list and restored the /home folder