Friday 22 June 2018

PIVPN no internet after connect


Set

:FORWARD ACCEPT [0:0]


Instead of




:FORWARD DROP [0:0]

in
/etc/iptables/rules.v4 

Wednesday 23 May 2018

Don't leak traffic if VPN goes down

iptables -I FORWARD -i br0 -o tun1 -j ACCEPT
iptables -I FORWARD -i tun1 -o br0 -j ACCEPT
iptables -I FORWARD -i br0 -o vlan2 -j DROP
iptables -I INPUT -i tun1 -j REJECT
iptables -t nat -A POSTROUTING -o tun1 -j MASQUERADE

Tuesday 5 December 2017

Undo Commits

Commited but not pushed to the remote?
git reset --soft HEAD^

Commit pushed to the remote?
git reset HEAD^ --hard
$ git push origin -f




Monday 27 November 2017

Resizing Partition on UBUNTU

SOURCE: 
https://askubuntu.com/questions/116351/increase-partition-size-on-which-ubuntu-is-installed/116367 
As a matter of fact, you CAN enlarge the root filesystem while Ubuntu is running (I learned this recently myself here) - this sounds incredible but it's true :)
Here's the list of steps for a simple scenario where you have two partitions, /dev/sda1 is an ext4 partition the OS is booted from and /dev/sdb2 is swap. For this exercise we want to remove the swap partition an extend /dev/sda1 to the whole disk.
As always, make sure you have a backup of your data - since we're going to modify the partition table there's a chance to lose all your data if you make a typo, for example.
Run sudo fdisk /dev/sda
  • use p to list the partitions. Make note of the start cylinder of /dev/sda1
  • use d to delete first the swap partition (2) and then the /dev/sda1 partition. This is very scary but is actually harmless as the data is not written to the disk until you write the changes to the disk.
  • use n to create a new primary partition. Make sure its start cylinder is exactly the same as the old /dev/sda1 used to have. For the end cylinder agree with the default choice, which is to make the partition to span the whole disk.
  • use a to toggle the bootable flag on the new /dev/sda1
  • review your changes, make a deep breath and use w to write the new partition table to disk. You'll get a message telling that the kernel couldn't re-read the partition table because the device is busy, but that's ok.
Reboot with sudo reboot. When the system boots, you'll have a smaller filesystem living inside a larger partition.
The next magic command is resize2fs. Run sudo resize2fs /dev/sda1 - this form will default to making the filesystem to take all available space on the partition.
That's it, we've just resized a partition on which Ubuntu is installed, without booting from an external drive.

Wednesday 16 November 2016

Moving from Jenkins (Tomcat) to Jenkins Standalone [UBUNTU]

SSH into ubuntu
sudo apt-get update
sudo apt-get install jenkins
sudo service jenkins stop
cd /var/lib/jenkins
rm -rf ./*
cp -a /var/lib/tomcat8/webapps/jenkins .
chown -R jenkins .
chgrp -R jenkins .
sudo service jenkins start

Thursday 30 June 2016

Jenkins Webhook, Only build Specific Branch after receiving web hook. e.g. only build master

With a web hook a request is made regardless of which branch it is on. Initially this would cause my Jenkins to initiate a build (on master) even when the commit was pushed to develop. To fix this we can follow these steps:


  • Open your jenkins project
  • configure it to use: Poll SCM (but leave the schedule blank)
  • save and exit

in Bitbucket / Github create a web hook and enter the following url (replacing your jenkins & git project details)

http://<your domain>/jenkins/git/notifyCommit?url=<your git repository url>
eg

http://fakewebsite.com:8080/jenkins/git/notifyCommit?url=git@bitbucket.org:faceuser/fakeproject.git

This will do the following:

  1. Send a web hook request to your jenkins
  2. Jenkins will process this request and look for Jenkins projects using the specified gitproject (e.g. git@bitbucket.org:faceuser/fakeproject.git)
  3. Jenkins will then poll git looking for changes on the specified branch





Jenkins unable to post to twitter due to Twitter-plugin not using SSL

Same problem as this
https://issues.jenkins-ci.org/browse/JENKINS-25740

 but the solution was to also replace jar the following files under
$jenkinsdir/plugins/twitter/WEB-INF/lib

twitter4j-core-3.0.3.jar with twitter4j-core-3.0.5.jar
twitter4j-async-3.0.3.jar with twitter4j-async-3.0.5.jar

Download from
http://central.maven.org/maven2/org/twitter4j/twitter4j-core/3.0.5/

reload jenkins deployment in tomcat manager and voila! it works!