webdiff
This is just a simple script for doing a diff of two web pages. #!/bin/bash TMP1=$(mktemp) TMP2=$(mktemp) wget -q $1 -O $TMP1 wget -q $2 -O $TMP2 diff $TMP1 $TMP2 rm -f $TMP1 $TMP2
This is just a simple script for doing a diff of two web pages. #!/bin/bash TMP1=$(mktemp) TMP2=$(mktemp) wget -q $1 -O $TMP1 wget -q $2 -O $TMP2 diff $TMP1 $TMP2 rm -f $TMP1 $TMP2
This is just a quick note to save this useful bit of information. I may make it into a script one day or use it in something else. echo ''|openssl s_client -connect localhost:636 2>/dev/null | openssl x509 -noout -enddate | sed 's/^not.*\=//'
Small script to run an instance of mysql in my home directory using the binary provided by the OS. Maybe some day I will make it more usable but for the time being it suits my needs. #!/bin/bash MYSQL_HOME=$HOME MYSQL_USER=$USER MYSQL_PORT=13306 ACTION=$1 if [ $ACTION == 'init' ]; then echo "initialising new mysql installation at $MYSQL_HOME/var/lib/mysql" rm -rf $MYSQL_HOME/var/lib/mysql mkdir -p $MYSQL_HOME/var/lib/mysql $MYSQL_HOME/mysql/data $HOME/var/lib/mysql/tmp mysql_install_db --user=$MYSQL_USER --datadir=$MYSQL_HOME/var/lib/mysql/data/ cat < $HOME/.my.cnf [mysqld] user=$MYSQL_USER datadir=$MYSQL_HOME/var/lib/mysql/data log-error=mysqld.log pid-file=mysqld.pid socket=$MYSQL_HOME/var/lib/mysql/tmp/mysql.sock port=$MYSQL_PORT [client] user=$MYSQL_USER socket=$MYSQL_HOME/var/lib/mysql/tmp/mysql.sock port=$MYSQL_PORT [safe_mysqld] log-error=mysqld.log pid-file=mysqld.pid port=$MYSQL_PORT EOT echo " Done" elif [ $ACTION == 'start' ];then echo -n "Starting mysqld as $MYSQL_USER on $MYSQL_PORT" nohup mysqld_safe &>/dev/null & echo " Done" elif [ $ACTION == 'stop' ];then PID=$(cat $MYSQL_HOME/var/lib/mysql/data/mysqld.pid) echo -n "Stopping mysql instance [$PID]" kill `cat $MYSQL_HOME/var/lib/mysql/data/mysqld.pid` echo " Done" else echo "Unknown command '$1'" fi UPDATED SCRIPT:
Have you ever needed to run a bunch of long running processes from a bash script and get their return codes ? I come across this issue quite frequently in my line of work. The most common one is where I need to run rsync to collect files from many machines then if successful run some other task. Depending on the number of servers and data this can take several hours to run sequentially and I don’t really like waiting around to check the output so that I can run the next task.
I quite often need to remove a single line from a file by its line number. The most common use case for me is the known_hosts file when I have reinstalled a system, I have in the past used vim and navigated to the line then removed it. This is all well and good but it gets to be a pain having to do it repeatedly, especially when you manage around 1000 servers and they get rebuilt frequently. Finally today I had had enough so wrote a little script to do this task easily. Hopefully someone else finds this useful
This post is here mainly because I always forget how to do it. This is one of the simplest ways to reinstall a Centos (will probably work for RHEL and maybe even Fedora) system without needing PXE or physical access to the machine. Make sure that you have tested your kickstart before you use it and don’t blame me if anything goes wrong. Save the following script and make it executable then run it. It will ask some questions about networking and hostname and then write a new grub stanza to your grub.conf. It will also download the correct kernel and initrd from the information you have given it and put them in the correct position for grub to find them when it boots.