Asides
In XenCenter Console – mount DVD drive in Ubuntu 14.04
In XenCenter Console – mount DVD drive in Ubuntu 14.04
When running Ubuntu 14.04 LTS as a guest under XenServer6.5 I was attempting to install xs-tools.iso by mounting it into server using the drop down box.
However at the console, i was unable to find /dev/cdrom or /dev/dvd* or /dev/sr* or anything that seemed to fit.
So I ran fdisk -l
#fdisk -l
and I found a disk I didnt recognize
Disk /dev/xvdd: 119 MB, 119955456 bytes 255 heads, 63 sectors/track, 14 cylinders, total 234288 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/xvdd doesn't contain a valid partition table
So I mounted it and looked at the contents
#mount /dev/xvdd /mnt #ls /mnt dr-xr-xr-x 4 root root 2048 Jan 27 04:08 Linux -r--r--r-- 1 root root 1180 Jan 27 04:08 README.txt -r--r--r-- 1 root root 65 Jan 27 04:07 AUTORUN.INF -r--r--r-- 1 root root 802816 Jan 27 04:07 citrixguestagentx64.msi -r--r--r-- 1 root root 802816 Jan 27 04:07 citrixguestagentx86.msi -r--r--r-- 1 root root 278528 Jan 27 04:07 citrixvssx64.msi -r--r--r-- 1 root root 253952 Jan 27 04:07 citrixvssx86.msi -r--r--r-- 1 root root 1925120 Jan 27 04:07 citrixxendriversx64.msi -r--r--r-- 1 root root 1486848 Jan 27 04:07 citrixxendriversx86.msi -r--r--r-- 1 root root 26 Jan 27 04:07 copyright.txt -r--r--r-- 1 root root 831488 Jan 27 04:07 installwizard.msi -r-xr-xr-x 1 root root 50449456 Jan 27 04:03 dotNetFx40_Full_x86_x64.exe -r-xr-xr-x 1 root root 1945 Jan 27 04:03 EULA_DRIVERS -r-xr-xr-x 1 root root 1654835 Jan 27 04:03 xenlegacy.exe -r-xr-xr-x 1 root root 139542 Jan 27 04:03 xluninstallerfix.exe
So I found it! Now just to install the tools and reboot
#cd Linux && ./install.sh #reboot
Create correct user privileges / grant to use for mysqldump
Create correct user privileges / grant to use for mysqldump
To make sure you have the correct user permissions for the backup user that you will use for dumping mysql databases for backup
mysql> GRANT SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'backup'@'localhost'; mysql> GRANT LOCK TABLES ON *.* TO 'backup'@'localhost';
Thanks to this post for the help
One Line WordPress Install
One Line WordPress Install
To install the latest version of WordPress to your current working directory in Linux you can run this command
#wget -O - https://wordpress.org/latest.tar.gz |tar --strip-components=1 -xvzf - wordpress/
Just make sure you are in your install directory when you run it
#cd /var/www/html
XenCenter – missing ‘Logs’ tab
XenCenter – missing ‘Logs’ tab
Xencenter has moved the status of actions somewhere for each Physical and VM from the very intuitive ‘logs’ tab location it was before. Here is where they moved it.
- At the bottom of the left pane there is an option called ‘Notifications’, when you click it you are automatically shown all of the the alerts (such as the status changes)
- At the top of the left pane whn you are clicked on Notifications you will notice that it has given you three options “Alerts”, “Updates” and “Events”.
- If you click on “Events” you will see the status of ongoing ‘Exports’ or transfers or other actions.
my btmp file is huge on linux, what do I do
my btmp file is huge on linux, what do I do
The /var/log/btmp file is one that tracks all of the login attempts on your machine. If it is huge it probably means someone is trying to brute force attack you computer.
the file is binary so you can not just view it, you have to use
#lastb|less
Most likely you will find that someone has been attempting to repeatedly hack your computer, consider setting up a firewall which limits the IP address that are allowed to login to your SSH port.
You could also install DenyHosts
#apt-get install denyhosts
One issue that can occur is that if you are getting attacked, the log size gets to large.
Most likely your logrotate.conf file has a /var/log/btmp entry in it. Update this file to rotate and compress the log file more frequently (see the logrotate documentation)
PHP Solution to http to https ajax call: No ‘Access-Control-Allow-Origin’ header is present on the requested resource
PHP Solution to http to https ajax call: No ‘Access-Control-Allow-Origin’ header is present on the requested resource
When submitting a form from an http:// site to an https:// via ajax, you will run into the following error in the Chrome console
XMLHttpRequest cannot load https://www.example.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.example.com' is therefore not allowed access
This problem can come about if your current url is http://www.example.com/ and you are using an ajax POST or GET request to the https://www.example.com site.
For example on http://example.com/login.php you might have some JQuery such as
$('div#login').load('https://example.com/loginform.php')
Or
$.post({url:'https://example.com/loginform.php' ,data: 'username=bob&password=pass123' ,success: function(data){ $('div#login').html('You are logged in') } })
To correct this, add the following PHP to the top of the loginform.php page. Note the HTTP_HOST variable which should make it so that if you are simply trying to access the https:// site using the exact same domain name you will not have to change the code
<?php header("Access-Control-Allow-Origin: http://$_SERVER[HTTP_HOST]"); ?>
Ubuntu Server Time Resetting
Ubuntu Server Time Resetting
We have a server that was having trouble resetting the date on the server to todays date and time, in the year 2020. It appeared that the problem happened randomly and in some cases it would happen and then go away. Here are some of the steps I went through to debug this.
My server has a daily 1:01 AM cronjob to the the date from another local server (to keep all of our servers in sync)
This command syncs the date with that server.
/usr/sbin/ntpdate -v my.localsever.com
Anytime I noticed the date off at 2020, when i would run this command and it would properly reset to the correct time, so it seems it has to be coming from somewhere other than the my.localserver.com
So I decide to try to pinpoint when this happened. Do to this I started a cron log, which dumps the date, every 30 seconds into a file, so I could look at that file to find out when the dates change
/bin/date >> /tmp/bin.date.log
Now, next time it happens I will have a history of the minute during which the issue happens and perhaps I can tie it to some process I have running.
Test for and run a dynamically named javascript function
Test for and run a dynamically named javascript function
Sometime in the world of dynamic coding, you need the ability to dynamically create and run javascript functions depending on whether the javascript function is defined on the page. (so i can run different code depending on the context)
function email_action(action,obj) { var functionname='email_action_'+action var t = setTimeout('alert("invalid function name: "'+functionname+'" n Cannot run email action: "'+action+')',100) if (typeof(eval(functionname))!= 'function') return; clearTimeout(t) var func = eval(functionname) func(obj) }
Check SPF Records when receiving mail in postfix
Check SPF Records when receiving mail in postfix
This simple install assumes you already have policyd installed
apt-get install postfix-policyd-spf-perl
Another tutorial, said that an executable file might be installed at /usr/sbin/policyd-spf, however it was installed elsewhere on my ubuntu 14.04 system, here is how I found it
#updatedb
#locate policyd-spf|bin
/usr/sbin/postfix-policyd-spf-perl
User the path to add this entry to your /etc/postfix/master.cfm
policy-spf unix - n n - - spawn
user=nobody argv=/usr/sbin/postfix-policyd-spf-perl
So, now we need to update /etc/postfix/main.cf by adding the following line
spf-policyd_time_limit = 3600s
and updateing the ‘smtpd_receiptient_restrictions’ to have the following in the list of services, I added mind after ‘permit_mynetworks’ and another ‘check_policy_service 127.0.0.1:10011’ entry I have.
smtpd_recipient_restrictions = permit_mynetworks, check_policy_service inet:127.0.0.1:10011, check_policy_service unix:private/policy-spf, .....
Reload and watch your logs
/etc/init.d/postfix restart grep spf /var/log/mail.log
Code Source Text and White Space Quick Count Evaluation Tool
Code Source Text and White Space Quick Count Evaluation Tool
I created a simple website utility which can be used to evaluate the white space in some code or returned from a website.
Paste in the code from your editor, or you can type in a URL and it will download the html and evaluate that
The results counts up all of your characters, shows you how much white space there is.
It also shows you how many blank lines you have, whether you are using tabs or spaces at the beginning of your lines (this is useful to me to help coordinate similar code indenting formats between developers)
This tool can be pretty useful when wanting to figure out things related to white space usage.
https://www.matraex.com/character-coding-evaluator.php
At the bottom of the reusults, every line is displayed with details of each line and how many spaces are at the beginning of the line
if you have suggestions, email me with ‘White Space Evaluation’ in the subject michael @ matraex.com.