Commit 2250f795 authored by Zéfling's avatar Zéfling 🎨
Browse files

2 scripts

- rotateImageExif.sh
- updateGeoIP.sh
parents
#! /bin/bash
#
# Exif Orientation remover
# Version 1.0
#
# -----------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2014-04-23 Zéfling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# -----------------------------------------------------------------------------
#
echo "------------------------------------------------------"
echo "----------- EXIF ORIENTATION REMOVER -----------------"
echo "------------------------------------------------------"
echo
echo " Picture rotation start "
# create a new folder
[ -d rotated ] ||mkdir rotated
# get the .JPG extensions and rename them in .jpg
#
LISTJPG=`ls -l |grep JPG |tail -n 1|awk {'print $8'}`
echo $LISTJPG
if [ $LISTJPG ]
then
echo "------------------------------------------------------"
echo "Rename .JPG extension in .jpg"
for i in *.JPG
do
NEWNAME=`ls |grep "$i"|cut -d "." -f1`
mv "$i" "$NEWNAME.jpg"
echo " - changing JPG to jpg for $i"
done
fi
# is there any .jpg to process in this folder ?
#
LISTJPG=`ls -l |grep jpg |tail -n 1 |awk {'print $8'}`
INDEX=1
if [ $LISTJPG ]
then
# size of list
SIZE=`find . -maxdepth 1 -name "*.jpg" -type f | wc -l`
echo "------------------------------------------------------"
find . -maxdepth 1 -name "*.jpg" -type f | while read -r i
do
# delete ./
i=${i:2}
ORIENTATION=`LANG=en exiv2 pr -p t "$i" 2>/dev/null | grep -a "Exif.Image.Orientation" | awk {'print $4 $5'}`
echo " $INDEX / $SIZE : “$i” has orientation “$ORIENTATION”"
if [ "$ORIENTATION" = "left,bottom" ]
then
echo " --> rotation left"
convert "$i" -rotate -90 rotated/"$i"
LANG=en exiv2 -M "set Exif.Image.Orientation Short 1" rotated/"$i"
elif [ "$ORIENTATION" = "right,top" ]
then
echo " --> rotation rigth"
convert "$i" -rotate 90 rotated/"$i"
LANG=en exiv2 -M "set Exif.Image.Orientation Short 1" rotated/"$i"
else
echo " --> no rotation"
cp "$i" rotated/
fi
((INDEX++))
done
fi
echo "------------------------------------------------------"
echo
echo "operation completed"
echo
\ No newline at end of file
#!/bin/bash
#
# GeoIP Databases Update
# Version 1.1
#
# updateGeoIP.sh
#
# SID Solutions
# http://sidsolutions.net
# Copyright (c) 01/13/2008
# Programmed by Sid McLaurin
#
# Adpated for Apache & regular Debian folders by kent1
#
# Description:
#
# Script to update all GeoIP databases
#
# Location:
#
# /opt/scripts/
#
# Changes:
# 01/02/2009 - Create an URL for the new location of the
# GeoIP.dat
# 20/07/2009 - Adaptation forApache & regular Debian
# folders by kent1
# Variables
URL=http://www.maxmind.com/download/geoip/database/
NUMURL=http://www.maxmind.com/download/geoip/database/asnum/
COUNTRYURL=http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/
GEODBS=( "GeoIP.dat.gz" "GeoIPv6.dat.gz" "GeoLiteCity.dat.gz" "GeoIPASNum.dat.gz" "GeoIPASNumv6.dat.gz" )
GEOPATH=/usr/share/GeoIP
GEOUSER=root
GEOGROUP=root
echo -e "\n\033[1;32m\tStarting GeoIP Database Update \033[0m"
# Change to GeoIP database directory
cd $GEOPATH
# Delete previous database
echo -e "\033[1;33mRemoving previous databases\033[0m ...............\c"
/bin/rm -f Geo*dat
echo -e "\033[1;32m Done! \033[0m"
# Get new databases
echo -e "\033[1;31mDownloading databases\033[0m"
for GEODB in ${GEODBS[@]} ; do
echo -e "\tDownloading \033[1;33m"$GEODB"\033[0m ..........\c"
if [ $GEODB = "GeoLiteCity.dat.gz" ] || [ $GEODB = "GeoIPv6.dat.gz" ] ; then
/usr/bin/wget $URL$GEODB > /dev/null 2>&1
elif [ $GEODB = "GeoIPASNum.dat.gz" ] || [ $GEODB = "GeoIPASNum.dat.gz" ] ; then
/usr/bin/wget $NUMURL$GEODB > /dev/null 2>&1
else
/usr/bin/wget $COUNTRYURL$GEODB > /dev/null 2>&1
fi
echo -e "\033[1;32m Done! \033[0m"
done
# Deflate new databases
echo -e "\033[1;31mDeflating databases\n\033[0m"
for GEODB in ${GEODBS[@]} ; do
echo -e "\tDeflating \033[1;33m"$GEODB"\033[0m ............\c"
/bin/gunzip $GEODB
echo -e "\033[1;32m Done! \033[0m"
done
# Set permissions
if [ "$GEOUSER" != "" ] || [ "$GEOGROUP" != "" ] ; then
echo -e "\033[1;31mSetting permissions\n\033[0m"
fi
# Set user permissions
if [ "$GEOUSER" != "" ] ; then
echo -e "\033[1;33m\tSetting user permissions to "$GEOUSER"\033[0m .........\c"
/bin/chown -R $GEOUSER $GEOPATH
echo -e "\033[1;32m Done! \033[0m"
fi
# Set group permissions
if [ "$GEOGROUP" != "" ] ; then
echo -e "\033[1;33m\tSetting group permissions to "$GEOGROUP"\033[0m ........\c"
/bin/chgrp -R $GEOGROUP $GEOPATH
echo -e "\033[1;32m Done! \033[0m"
fi
echo -e "\033[1;31mTweak City Plugin GeoIP\n\033[0m"
# Tweak City Plugin GeoIP
echo -e "\033[1;33m\tCopy GeoIPLiteCity GeoIPCity\033[0m ........\c"
cd /usr/share/GeoIP
cp GeoLiteCity.dat GeoIPCity.dat
echo -e "\033[1;32m Done! \033[0m"
# Done!
echo -e "\033[1;32m\tGeoIP Database update completed! \033[0m"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment