Send HTML mail from command line (Newsletter)

#!/bin/bash
 
# http://www.panticz.de/Send-email-from-console
 
INPUT=./adr_uniq.txt
CONTENT=./nl_de.html
SUBJECT="YOUR_SUBJECT"
LOG=./nl_de_$(date -I).log
 
# send 
for i in $(cat $INPUT); do
   mail -a 'Content-type: text/html;' -s "$SUBJECT" "$i" < $CONTENT
   echo "$i - $?" | tee -a $LOG
done

Install Ubuntu Hardy from HDD

#!/bin/bash
 
# download netboot image
wget http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/netboot.tar.gz -P /tmp
 
# extract and copy install files
tar xzf /tmp/netboot.tar.gz -C /tmp
mkdir /boot/ubuntu
cp /tmp/ubuntu-installer/amd64/initrd.gz /boot/ubuntu/
cp /tmp/ubuntu-installer/amd64/linux /boot/ubuntu/
 
# create GRUB menu entry
cat <<EOF> /etc/grub.d/49_ubuntu
#!/bin/sh
exec tail -n +4 $0
 
menuentry "Network Ubuntu install" {
    root (hd0,0)
    kernel /boot/ubuntu/linux
    initrd /boot/ubuntu/initrd.gz
}
EOF
chmod 

Oracle queries

-- show configuration
show parameters
 
-- find constraint
SELECT *
FROM all_constraints
WHERE constraint_name = 'SYS_C00381400';
 
-- select a random row from table
SELECT column FROM 
   SELECT column FROM TABLE
   ORDER BY DBMS_RANDOM.VALUE
)
WHERE ROWNUM = 1
 
-- update materialized view
BEGIN
   dbms_snapshot.refresh('SCHEMA.MATERIALIZED_VIEW_NAME'); 
END;
 
-- view scheduler jobs
SELECT * FROM user_scheduler_jobs
 
-- get lock on table (NOWAIT)
SELECT username,v$lock.sid,TRUNC(id1/POWER(2,16)) rbs,BITAND(id1,TO_NUMBER('ffff','xxxx'))+0 slot,id2 seq,lmode,request
FROM 

MySQL Queries

-- view hostname
select @@hostname;
 
-- view version
select version();
 
-- view engines
show engines;
 
-- list databases
show databases;
 
-- change database
use mysql;
 
-- show tables in database
show tables;
 
-- show table informations
show table status;
 
-- show engines
show engines;
 
-- show bin_log info
show variables like '%log_bin%';
 
-- list users
select user, host from mysql.user;
 
-- delete user
DROP USER 'USER_NAME'@'%';
 
-- set user password
--SET PASSWORD FOR 'USER_NAME'@'%' = PASSWORD('NEW_PASSWORD')
use mysql;
update user set password=PASSWORD(

Create webserver info page

#!/bin/bash
 
cat <<EOF> "$(grep DocumentRoot /etc/apache2/sites-available/default | cut -d " " -f2)/phpinfo.php"
<?php
phpinfo();
?>
EOF

Copy MySQL Database

#!/bin/bash
 
mysqldump --host=${DB_FROM_HOST} --user=${DB_FROM_USER} --password=${DB_FROM_PASS} ${DB_FROM_NAME} | \
mysql --host=${DB_TO_HOST} --user=${DB_TO_USER} --password=${DB_TO_PASS} ${DB_TO_NAME}

PHP and Javascript framebreaker

<?php
if($_SERVER['PHP_SELF'] != "/index.php") {
echo '<script language="javascript" type="text/javascript">
<!--
	window.onload = function() {
		if (top.location != location) {
			top.location.href = document.location.href ;
		}
	}
//-->
</script>';
}
?>

Instal RoundCube (Webmail)

# set domU parameter
[ -z $DOMAIN_NAME ] && DOMAIN_NAME=webmail
[ -z $DOMAIN_MAC ] && DOMAIN_MAC=00:11:22:7d:7e:7f
[ -z $DOMAIN_RAM ] && DOMAIN_RAM=256Mb
[ -z $DOMAIN_HDD ] && DOMAIN_HDD=2Gb
 
# create domU
http://www.panticz.de/Xen-domU-ubuntu-jaunty
 
# add to autostart (optional)
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto
 
# start domU
xm create -c ${DOMAIN_NAME}
 
# install webmail
http://www.panticz.de/install_roundcube

Compile stress test for linux

#!/bin/bash
 
LINK="http://weather.ou.edu/%7Eapw/projects/stress/stress-1.0.0.tar.gz"
 
# download and extract
wget $LINK -P /tmp
cd /tmp/
tar xzf stress-1.0.0.tar.gz 
cd stress-1.0.0/
 
# compile
./configure && make
 
# optionaly you can install it or use the executable in src folder
make install

Install build-essential

#!/bin/bash
 
sudo apt-get -y install build-essential
Syndicate content