Skip to content

Instantly share code, notes, and snippets.

@onel0p3z
Last active December 17, 2015 15:29
Show Gist options
  • Save onel0p3z/5632448 to your computer and use it in GitHub Desktop.
Save onel0p3z/5632448 to your computer and use it in GitHub Desktop.
From, my HOW TO's
Add a second HDD
In this tutorial we will add a second hard drive to our machine running Debian linux.
If you have just added a virtual disk, make sure you restart the virtual machine before mounting the new disk.
First we'll have to find out what the device name is for this disk
fdisk -l
This will give you output similar to this:
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2517 20217771 83 Linux
/dev/sda2 2518 2610 747022+ 5 Extended
/dev/sda5 2518 2610 746991 82 Linux swap / Solaris
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Next we'll partion the new disk using the following command:
cfdisk /dev/sdb
New -> Primary -> Specify size in MB
Write
Quit
Format the new disk using the ext3 filessystem
mkfs.ext3 /dev/sdb1
Mounting the drive to a new folder
mkdir /disk2
mount -t ext3 /dev/sdb1 /disk2
You can name the folder whatever your want and place it in subfolders of another drive, for example /var/disk2
Add the new drive to fstab so that it will automatically mount when we reboot the machine. Add the following line to your fstab file (pico /etc/fstab)
/dev/sdb1 /disk2 ext3 defaults,errors=remount-ro 0 1
Now your new hard disk is mounted.
Backup installed packages
sudo dpkg --get-selections>packages.txt
sudo dpkg --clear-selections
sudo dpkg --set-selections<packages.txt
sudo apt-get update
sudo apt-get dselect-upgrade
Change Django password
python manage.py shell
then use following script in shell
from django.contrib.auth.models import User
User.objects.filter(username__icontains='a part of your username')
will list you all usernames contains what you write. if you recognize yur username from the list:
usr = User.objects.get(username__icontains='your username')
usr.set_password('raw password')
Check failed registrations from Asterisk log
for f in /var/log/asterisk/*; do echo "${f}:" && egrep -i 'Registration from.*failed for.*' ${f} ; done
Counting failed registrations from Asterisk logs
for f in /var/log/asterisk/*; do echo "${f}:" && egrep -ci 'Registration from.*failed for.*' ${f} ; done
Getting IP Addr
# Assigned IP to interface
ifconfig | sed -n '2p'| awk -F: '{print $2}'| awk '{print $1}'
# External IP behind NAT
curl -s http://checkip.dyndns.org/ | cut -d ' ' -f 6 | sed s/"body\|html\|<\|>\|\/"//g
Install BigBlueButton in Ubuntu
Before you install
These instructions require you install BigBlueButton 0.80 on a Ubuntu 10.04 32-bit or 64-bit server (or desktop). We've not tested the installation on earlier or later versions of Ubuntu.
We recommend installing BigBlueButton on a dedicated (non-virtual) server for optimal performance. To install BigBlueButton, you'll need root access to a Ubuntu 10.04 server with
2 GB of memory (4 GB is better)
Dual-core 2.6 GHZ CPU (quad core is better)
Ports 80, 1935, 9123 accessible
Port 80 is not used by another application
50G of free disk space (or more) for recordings
In addition to the above, the locale of the server must be en_US.UTF-8. You can verify this by
$ cat /etc/default/locale
LANG="en_US.UTF-8"
To verify that port 80 is not in use by another application, you can type
sudo apt-get install lsof
lsof -i :80
sudo apt-get update
sudo apt-get dist-upgrade
# Add the BigBlueButton key
wget http://ubuntu.bigbluebutton.org/bigbluebutton.asc -O- | sudo apt-key add -
# Add the BigBlueButton repository URL and ensure the multiverse is enabled
echo "deb http://ubuntu.bigbluebutton.org/lucid_dev_08/ bigbluebutton-lucid main" | sudo tee /etc/apt/sources.list.d/bigbluebutton.list
echo "deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install zlib1g-dev libssl-dev libreadline5-dev libyaml-dev build-essential bison checkinstall libffi5 gcc checkinstall libreadline5 libyaml-0-2
vim ruby.sh
#!/bin/bash
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
tar xvzf ruby-1.9.2-p290.tar.gz
cd ruby-1.9.2-p290
./configure --prefix=/usr\
--program-suffix=1.9.2\
--with-ruby-version=1.9.2\
--disable-install-doc
make
sudo checkinstall -D -y\
--fstrans=no\
--nodoc\
--pkgname='ruby1.9.2'\
--pkgversion='1.9.2-p290'\
--provides='ruby'\
--requires='libc6,libffi5,libgdbm3,libncurses5,libreadline5,openssl,libyaml-0-2,zlib1g'\
--maintainer=brendan.ribera@gmail.com
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.2 500 \
--slave /usr/bin/ri ri /usr/bin/ri1.9.2 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.2 \
--slave /usr/bin/erb erb /usr/bin/erb1.9.2 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.2
sudo update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.2 500
chmod +x ruby.sh
./ruby.sh
ruby -v && gem -v
sudo gem install hello
sudo apt-get install bigbluebutton
sudo apt-get install bbb-demo
sudo bbb-conf --clean
sudo bbb-conf --check
http://code.google.com/p/bigbluebutton/wiki/BBBConf
Install Codec g729
#!/bin/bash
if [ "`uname -m`" = "i686" ]; then # system is x86_32
cd /usr/lib/asterisk/modules
echo "We are in: `pwd`"
fi
# system is x86_64
cd /usr/lib64/asterisk/modules
echo "We are in: `pwd`"
# Asterisk Version
#asterisk -v | grep Copy | awk '{print $2}'
# Asterisk 1.8
#wget http://asterisk.hosting.lv/bin/codec_g729-ast18-gcc4-glibc-x86_64-core2.so
#mv codec_g729-ast18-gcc4-glibc-x86_64-core2.so codec_g729.so
# Asterisk 10
wget http://asterisk.hosting.lv/bin/codec_g729-ast100-gcc4-glibc-x86_64-core2.so
mv codec_g729-ast100-gcc4-glibc-x86_64-core2.so codec_g729.so
chmod 0755 codec_g729.so
rasterisk -x 'module load codec_g729.so' && rasterisk -x 'core show translation'
Install HTOP
#!/bin/bash
yum -y install make ncurses ncurses-devel gcc
cd /tmp
wget http://sourceforge.net/projects/htop/files/latest/download
tar xvzf htop-1.0.2.tar.gz
cd htop-1.0.2
./configure
make
make install
Install rootsh
wget http://sourceforge.net/projects/rootsh/files/rootsh/1.5.3/rootsh-1.5.3.tar.gz/download
tar -zxvf rootsh-1.5.3.tar.gz
Create logs directory :
mkdir -vp /secure/admins-logs
./configure --disable-syslog --disable-linenumbering --with-logdir=/secure/admins-logs/
make && make install
Create a group for your admins so limited users can write to this folder.
groupadd admins
Creating a testadmin user and adding it to the group.
useradd testadmin
usermod -G testadmin admins
Applying appropriate permissions to logs folder & apply attributes.
chmod 770 /secure/admins-logs
chgrp admins /secure/admins-logs
chattr +a /secure/admins-logs
Edit /etc/shells – to allow our new loggable shell.
echo "/usr/local/bin/rootsh" >> /etc/shells
Enable logging for our user “testadmin”
vim /etc/passwd
search for a user testadmin and replace /bin/bash with /usr/local/bin/rootsh
Install VMware Tools from CLI
#!/bin/bash
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom/
cd /media/cdrom/
cp VMwareTools-8.3.7-341836.tar.gz /tmp
cd /tmp
tar vzxf VMwareTools-8.3.7-341836.tar.gz
cd vmware-tools-distrib/
./vmware-install.pl
OpenVZ Multiple NICs
Via 'man vzctl', for veth, you should end up with something like:
vzctl set <VMID> --netif_add eth<N>,,,,vmbr<M> --save
for adding an interface eth<N> in the container <VMID> to bridge vmbr<M> in the host.
To remove eth<N> from container <VMID> trigger:
vzctl set <VMID> --netif_del eth<N> --save
Serial Port in KVM
If you want to access the COM/serial port of your host machine from a KVM virtual machine in Proxmox VE, simply do the following :
vim /etc/qemu-server/104.conf
where 104 is the ID of the VM
add "args: -serial /dev/ttyS0" to the end of the file
It should look like this :
name: testVM
ide2: debian-500-i386-netinst.iso,media=cdrom
smp: 1
vlan0: rtl8139=XX:XX:XX:XX:XX:XX
bootdisk: ide0
ide0: vm-104-disk.qcow2
ostype: other
memory: 256
args: -serial /dev/ttyS0
If the VM is already running, you may have to stop the VM completely and start it again for it to see the COM port.
If you simply reboot the machine, it may not see it.
Site-2-Site OpenVPN
gwA # cat /etc/openvpn/server.conf
# gwA
local 172.20.0.1
port 1194
proto udp
dev tun
topology subnet
mode server
tls-server
ifconfig 10.0.0.1 255.255.255.0
route 192.168.2.0 255.255.255.0 10.0.0.2
route 192.168.3.0 255.255.255.0 10.0.0.3
client-config-dir ccd
# snip rest of config
gwA # cat /etc/openvpn/ccd/gwB
ifconfig-push 10.0.0.2 255.255.255.0
push "route 192.168.1.0 255.255.255.0 10.0.0.1"
iroute 192.168.2.0 255.255.255.0
gwA # cat /etc/openvpn/ccd/gwC
ifconfig-push 10.0.0.3 255.255.255.0
push "route 192.168.1.0 255.255.255.0 10.0.0.1"
iroute 192.168.3.0 255.255.255.0
Static IP on OpenVZ RHEL container
cd /etc/sysconfig/network-scripts/
Create the ethX interface
vim ifcfg-ethX
Insert the following Info:
DEVICE=ethX
BOOTPROTO=static
DHCPCLASS=
HWADDR=(ifconfig -look at HWadd)
IPADDR=x.x.x.x
NETMASK=255.255.255.0
ONBOOT=yes
Create the gateway and DNS domain entries:
vim /etc/sysconfig/network
Insert:
NETWORKING=yes
HOSTNAME=YOUR.HOSTNAME.COM
GATEWAY=x.x.x.x.x
Setup your nameservers:
vim /etc/resolv.conf
Insert:
nameserver x.x.x.x
And finally restart the networking interface:
Code:
/etc/init.d/network restart
Static routes from CLI
********************************************************
RHEL / CentOS LINUX STATIC ROUTING FOR TWO INTERFACES:
********************************************************
you can add static router for eth0 network interface by editing /etc/sysconfig/network-scripts/route-eth0
file to define static routes for eth0 interface:
# cat /etc/sysconfig/network-scripts/route-eth0
Sample Output:
GATEWAY0=192.168.1.254
NETMASK0=255.255.255.0
ADDRESS0=192.168.1.1
GATEWAY1=10.0.0.1
NETMASK1= 255.255.255.0
ADDRESS1=10.0.0.2
How do I define static routing for network 10.0.0.0/8 via 10.9.38.65 router?
Open /etc/sysconfig/network-scripts/route-eth0:
# vi /etc/sysconfig/network-scripts/route-eth0
Append following line:
10.0.0.0/8 via 10.0.0.1
Save and close the file. Restart networking:
# service network restart
Verify new routing table:
# route -n
# ip route show
You can add static route using following command:
ip route add {NETWORK} via {IP} dev {DEVICE}
For example network 192.168.1.0/24 available via 192.168.1.254:
# ip route add 192.168.1.0/24 via 192.168.1.254 dev eth1
********************************************************
DEBIAN / UBUNTU LINUX STATIC ROUTING FOR TWO INTERFACES:
********************************************************
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
### static routing ###
post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw X.X.X.X
pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw X.X.X.X
auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 4.2.2.1 8.8.8.8
USB passthrough on OpenVZ
# stop machine
vzctl stop XXX
# share "device" to container XXX with "rw"(read,write) permissions
vzctl set XXX --devnodes device:rw --save
#check config
cat /etc/pve/openvz/XXX.conf
# start machine
vzctl enter XXX
# enter machine
vzctl enter XXX
# check device is added
ls -la | grep device
## NOT REQUIRED ##
vzctl exec 1000 chown -R user:group /dev/device
vzctl exec 1000 chown -R user:group /lib/udev/devices/device
adduser user
chown -R user:group /dev/device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment