posted this in Linux, Mongo, Ubuntu on May 3rd, 2013 To make Mongo DB SSL on Ubuntu 12.04 you need to either purchase it or compile from source.
To make compiling from source easy here’s a script to help you out!
Mongo Compile SSL from Source Script
Note: Make sure you are not running an EC2 Small instance or you will run out of space! . . . → Read More: Howto make Mongo SSL on Ubuntu 12.04
Recently I tried passing a bash variable to perl command in bash script, it didn’t end well.
Troy Engel from http://tacticalvim.wordpress.com/ was nice enough to point out the issue:
use sed instead of perl for what you need; it’s simpler, faster and uses the bash variables easily.
I set up a test script /home/someuser/test.sh to show:
. . . → Read More: passing bash variable to perl command in bash script
posted this in Admin, MYSQL, php, Wordpress on December 4th, 2012 Goal: Update wordpress post with PHP cli
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
< ?php $con = mysql_connect("localhost","root","[redacted]"); if (!$con) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("wordpress")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $myfileText = mysql_real_escape_string(file_get_contents('./code_for_wordpress.html',true)); $sql = "UPDATE `[your_instance_prefix]_posts` SET `post_content` = '$myfileText' WHERE `ID` like '1397';"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } mysql_close($con); ?> |
posted this in Apache, bash, Linux, Redhat Centos on October 26th, 2012 Objective: Prep dev httpd.conf for production
Tasks:
Remove jenkins virtual host entry (which starts with a comment line “#Start Jenkins”) Replace .dev with nothing (ex: www.dev.example.com becomes www.example.com) Replace debug with error (ex: Loglevel debug becomes Loglevel error) Sed to remove lines after match
In this example we will use sed delete all lines after . . . → Read More: sed delete all lines after
posted this in MYSQL on September 19th, 2012 To manually update the CDN Sync Tool table (for wordpress plugin CDN Sync Tool) try this MySQL Insert Statement:
Replace the id with the latest id on your table
|
|
Manually insert row to cdn sync table INSERT INTO `wordpressdb`.`prefix_cst_new_files` (`id`, `file_dir`, `remote_path`, `changedate`, `synced`) VALUES (1567,'/full/path/to/file/filename.txt','filename.txt','1345062888','1'); |
To confirm your work:
|
|
SELECT * FROM `wordpressdb`.`prefix_cst_new_files` where remote_path LIKE `%.txt`; |
posted this in bash, Linux, Redhat Centos, Ubuntu on September 13th, 2012 useradd script
to add multiple users to a system and force them to change their password upon login try the following script:
Redhat
|
|
# for name in someuser anotheruser yetanotheruser; do useradd $name; echo 'password' | passwd --stdin $name; chage -d 0 $name; done |
The above script will add three users to the system (someuser anotheruser yetanotheruser) with the password “password” and set the password age to zero. This forces them to change their password . . . → Read More: redhat add multiple users
posted this in Linux, perl, Redhat Centos, Ubuntu on September 13th, 2012 I spent forever trying to figure out how to unwrap an apache access_log that was splitting requests between two lines. I finally found the answer!
Create a perl script called unwrap.pl and run the script like this:
|
|
# perl unwrap.pl access_log > accesslog2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/bin/env perl use strict; my $sentinel = 0; my $previous_line; my $result = ""; sub early_indent { # line next_line my $line = shift(@_); my $next_line = shift(@_); my @words = split(' ', $next_line); return (length ($line . " " . $words[0]) < length($next_line)); } while (<>) { my $this_line = $_; chomp $this_line; if ($sentinel) { if (($this_line eq "") || ($previous_line eq "") || ($this_line =~ /^[^A-Za-z0-9]/) || early_indent($previous_line, $this_line)) { $result .= $previous_line . "\n"; } else {$result .= ($previous_line . " "); } } $previous_line = $this_line; $sentinel = 1; } |
I’ve created a Bash Server Backup Script that will backup your MySQL databases (each database separately in to .sql and .xml files) and your main directories (/var/log, /var/www/html, /etc, /home, /root) to a timestamped directory. Feel free to re-use or hack up however you’d like
Here’s my Bash Server Backup Script: Download the script here . . . → Read More: Bash Server Backup Script
posted this in MSSQL on June 27th, 2012 To reset the mysql root password follow these steps 1. Stop running mysql instances
1a. If that doesn’t work then kill all running mysql instances
1. Stop running mysql instances
2. Start Mysql in safe mode
|
|
# mysqld_safe --skip-grant-tables |
3. Run these command replacing somepassword with your new password
|
|
mysql> update mysql.user set Password=PASSWORD('somepassword') where user='root'; mysql> flush privileges; mysql> exit; |
4. Start mysqld again . . . → Read More: Reset mysql root password
posted this in Apache, c#, IIS on April 13th, 2012 Nathan Bridgewater explained how to configure multiple reverse proxies properly with apache and IIS (without losing original domain name). I’m reposting this for myself to keep a record of this fine work.
multiple reverse proxy host broken iis serving up local server name instead of the ServerName that was originally passed to it. How to . . . → Read More: multiple reverse proxy host broken
|
|