#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.1.0 #Date: 2009-07-07 #System: Ubuntu/Debian GNU/Linux #Category Thunar scripts #Name: Create Gallery #Description: Create an online static HTML image gallery and upload with FTP #Command: x-terminal-emulator --fullscreen -e /usr/share/pct-thunar-scripts/scripts/create-gallery %F #Patterns: * #Directories: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Create Gallery" DESCRIPTION=$"Create an online static HTML image gallery and upload with FTP" cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" check_program() { application="$1" if [ ! -e /usr/bin/$application ] then cecho "red" $"$application not found, installing now" sudo apt-get install "$application" fi } cecho "green" $"process these files(s):" for I in "$@" do echo "$I" done for I in "$@" do cecho "green" $"starting with: " echo "$I" cecho "green" -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then continue fi check_program lazygal check_program lftp configfile="$HOME/.${0##*/}" if [ -f "$configfile" ]; then echo $"found $configfile, loading settings" . "$configfile" else cecho "green" $"configuration settings not found, creating template now" echo 'LAZYGAL_EXTRARG="--clean-destination --optimize --progressive --check-all-dir"' | tee "$configfile" echo 'FTP_USER="user@domain"' | tee --append "$configfile" echo 'FTP_PASS="password"' | tee --append "$configfile" echo 'FTP_HOST="ftp://ftp.domain.com/"' | tee --append "$configfile" echo 'FTP_LOCATION="pathonftp/"' | tee --append "$configfile" echo 'WEBSITE="http://domain/lazygal/"' | tee --append "$configfile" cecho "green" $"template created, please change the settings at:" echo "$configfile" continue fi if [ -z "$GALLERY" ]; then GALLERY="$I" cecho "green" $"source for the gallery is located at:" echo "$GALLERY" fi if [ -z "$OUTPUT" ]; then OUTPUT="$HOME/lazygal" cecho "green" $"output location for the gallery will be:" echo "$OUTPUT" fi if [ ! -d "$GALLERY" ]; then cecho "red" 1>&2 $"gallery location does not exist, closing now!" continue fi if [ ! -d "$OUTPUT" ]; then mkdir --verbose --parents "$OUTPUT" fi cecho "green" $"starting to create the image gallery now" command="lazygal --output-directory=$OUTPUT $LAZYGAL_EXTRARG $GALLERY" echo $"command: $command" cecho "green" $"command output:" lazygal --output-directory="$OUTPUT" $LAZYGAL_EXTRARG "$GALLERY" if [ "$?" = "1" ]; then cecho "red" 1>&2 $"error, when running gallery creation command, closing now!" continue fi cecho "green" $"starting to upload the online image gallery now" echo "FTP_USER:$FTP_USER, FTP_HOST:$FTP_HOST, FTP_LOCATION:$FTP_LOCATION" dirname=${OUTPUT%/*} file=${OUTPUT##*/} cd "$dirname" echo "open -u $FTP_USER,$FTP_PASS $FTP_HOST" > $HOME/lftp.script echo "mirror --reverse $file $FTP_LOCATION" >> $HOME/lftp.script echo "quit" >> $HOME/lftp.script cecho "green" $"command output:" lftp -f $HOME/lftp.script if [ "$?" = "1" ]; then cecho "red" 1>&2 $"error, when running ftp upload command, closing now!" continue else echo $"ftp upload seem to have run successful, continuing now" cecho "green" $"website:" echo "$WEBSITE" fi rm $HOME/lftp.script cd $HOME cecho "green" $"completed" echo "---------------" done cecho "green" $"done" echo -n $"press the [enter] key to close and exit this window " read input exit 0