#!/bin/bash # BASE CONFIGURATION file_dir="/home/erelance/Drop_Off" done_dir="/home/erelance/done" dest_dir="/home/erelance/Drop_Off" log_dir="/home/erelance/log" # log date_short="+%d-%m-%Y" date_long="+%d-%m-%Y %H:%M:%S" log_file="$log_dir/error-"$(date "$date_short")".log" if [ ! -d "$done_dir" ];then mkdir "$done_dir" fi if [ ! -d "$log_dir" ];then mkdir "$log_dir" fi for i in $(ls $file_dir/*.{csv,txt}) do scp_return=$(scp $i erelance@sub.domain.tld:$dest_dir 2>&1) if [[ $? == 0 ]]; then mv $i $done_dir else echo $(date "$date_long")"|$i|$scp_return" >> $log_file fi done find $log_dir -maxdepth 1 -type f -mtime +14 -name *.log -exec rm {} \; 2>&1
Tag Archives: Linux
deploy.sh
#!/bin/bash function usage { echo "Usage:" echo "$0 --all|-a website" echo "$0 --sync|-s website" echo "$0 --deploy|-d website" } case $2 in 'website') project_repository="http://repository.ctld/website/trunk/" dir="/home/hio/repository/website.com/" prod_dir="/home/www/website.com/" exclude_list=".svn frontend_test.php frontend_dev.php auth.php backend_dev.php" ;; *) usage exit 1 esac if [[ $1 == "--all" || $1 == "-a" ]]; then $0 --sync $2 $0 --deploy $2 fi if [[ $1 == "--sync" || $1 == "-s" ]]; then if [ ! -d "$project_repository" ]; then svn co $project_repository $dir else svn up $dir fi fi for e in $exclude_list do excludes="$excludes --exclude '$e'" done if [[ $1 == "--deploy" || $1 == "-d" ]]; then rsync="sudo rsync -rha --stats $excludes $dir $prod_dir" echo $rsync eval $rsync sudo chown www-data:www-data -R $prod_dir fi
memo mdadm
Déclarer un disque défaillant et le retirer du raid
mdadm --manage /dev/md2 --set-faulty /dev/sdb1 mdadm --manage /dev/md2 --remove /dev/sdb1
Stopper un raid
mdadm --stop /dev/md2 mdadm --remove /dev/md2
Rajouter/remplacer un disque dans un raid et resynch
mdadm --assemble /dev/md2 /dev/sdb1
Information sur un raid
mdadm --detail /dev/md2
Sauvegarder la conf mdadm
mdadm --detail --scan --verbose >> /etc/mdadm/mdadm.conf
Générer CSR
openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr
Country Name (2 letter code) [AU]: FR State or Province Name (full name) [Some-State]: . Locality Name (eg, city) []: Town Organization Name (eg, company) [Internet Widgits Pty Ltd]: company Organizational Unit Name (eg, section) []: IT Common Name (eg, YOUR name) []: www.website.tld Email Address []: A challenge password []: An optional company name []:
cat server.csrmass_update.sh
#!/bin/bash hosts="hio@host1.com hio@host2.com hio@host3.com hio@host4.com hio@host5.com" cmd="echo 'updating ...';sudo aptitude update >> /dev/null;sudo aptitude safe-upgrade -y;echo 'done'" for i in $hosts do echo "###### connecting to $i ..." ssh -t $i $cmd echo "" done
install_symfony2.sh
#!/bin/bash function usage { echo "Usage:" echo "$0 /home/www/mySf2Project" } if [[ $1 == "" ]]; then usage exit 1 fi cd $1 if [ -d "app/" ]; then echo "already installed, do a <git pull> if you want an update :)" exit 1 fi git clone git://github.com/symfony/symfony-standard.git mv symfony-standard/* . mv symfony-standard/.git* . rmdir symfony-standard bash bin/vendors.sh && php bin/build_bootstrap.php echo "chmod -R 777 app/cache/ app/logs/" chmod -R 777 app/cache/ app/logs/ exit 0
import.sh
#!/bin/bash date_format="+%d/%m/%Y %H:%M:%S" dir="/home/smile" mysql_client="mysql -u import -pP4S5W0RD" echo `date "$date_format"`" start" cd $dir if [ ! -d "tmp" ];then mkdir tmp fi if [ ! -d "bak" ];then mkdir bak fi for i in `ls *.sql.gz` do f=`echo $i|cut -d'.' -f1-2` db_name=`echo $i|cut -d'-' -f1` echo `date "$date_format"`" gzip -d $i -c > tmp/$f" gzip -d $i -c > tmp/$f echo `date "$date_format"`" mysql -u import -p***** $db_name < tmp/$f" $mysql_client <<EOF DROP DATABASE $db_name ; CREATE DATABASE $db_name ; EOF $mysql_client $db_name < tmp/$f mv $i bak/$i rm tmp/$f done echo `date "$date_format"`" end"
10/04/2011 08:00:01 start 10/04/2011 08:00:01 gzip -d bayardsso_prod-201104100542.sql.gz -c > tmp/bayardsso_prod-201104100542.sql 10/04/2011 08:00:02 mysql -u import -p***** bayardsso_prod < tmp/bayardsso_prod-201104100542.sql 10/04/2011 08:01:18 gzip -d notretemps-201104090006.sql.gz -c > tmp/notretemps-201104090006.sql 10/04/2011 08:01:45 mysql -u import -p***** notretemps < tmp/notretemps-201104090006.sql 10/04/2011 08:33:20 gzip -d notretemps_outils-201104090006.sql.gz -c > tmp/notretemps_outils-201104090006.sql 10/04/2011 08:33:20 mysql -u import -p***** notretemps_outils < tmp/notretemps_outils-201104090006.sql 10/04/2011 08:33:20 gzip -d phosphore-201104100040.sql.gz -c > tmp/phosphore-201104100040.sql 10/04/2011 08:34:20 mysql -u import -p***** phosphore < tmp/phosphore-201104100040.sql 10/04/2011 10:23:21 end
arbo.sh
#!/bin/bash dir="/home/www/bayardcdn.com/bj.emailing" month[1]=`date +%Y/%m` month[2]=`date +%Y/%m --date "+1 month"` month[3]=`date +%Y/%m --date "+2 month"` month[4]=`date +%Y/%m --date "+3 month"` m_nb=`seq 1 4` chmod u+w,g+w,o-w -R $dir for i in $m_nb do if [ ! -d "$dir/${month[$i]}" ]; then echo "mkdir -p $dir/${month[$i]}" mkdir -p "$dir/${month[$i]}" fi done chmod u-w,g-w,o-w -R $dir for i in $m_nb do if [ -d "$dir/${month[$i]}" ]; then echo "chmod u+w,g+w -R $dir/${month[$i]}" chmod u+w,g+w -R $dir/${month[$i]} fi done
wwwperm.sh
#!/bin/bash www=$2 dirperms="750" fileperms="640" owner="www-data:www-data" function usage { echo "Usage:" echo "$0 --all /home/www" echo "$0 --dir /home/www" echo "$0 --file /home/www" echo "$0 --owner /home/www" } if [[ $1 == "" || $2 == "" ]]; then usage exit 1 fi case $1 in '--all') bash $0 --dir $www bash $0 --file $www bash $0 --owner $www ;; '--dir') echo "fixing dirs in $www ..." find $www -type d -exec sh -c "chmod $dirperms '{}'" \; ;; '--file') echo "fixing files in $www ..." find $www -type f -exec sh -c "chmod $fileperms '{}'" \; ;; '--owner') echo "fixing owner in $www ..." chown -R $owner $www ;; *) usage exit 1 esac exit 0
LINUX « udev: renamed network interface eth0 to eth1″
Corriger en editant et en remettant dans l’ordre les bonne carte eth avec les bonne interface
fichier a editer
/etc/udev/rules.d/70-persistent-net.rules
Changer les « NAME= » par les bonnes interfaces
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:65:ae:04", NAME="eth1"
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1c:c0:01:5f:e0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"Probleme du au fait, que vous avez rajoutez une carte ethernet alors que la carte mere en possedai deja une,
ca a pu fonctionner pendant un moment, et un jour pour une raison X (changement de kernel ou autre), la carte ethernet qui est sur la carte mere est passer en eth0 et n ‘etant pas connecter au reseau. bye bye, plus de ssh ni rien.