From: Francois Fleuret Date: Sat, 18 May 2013 11:03:14 +0000 (+0200) Subject: Removed lame scripts. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=6473993b691c6280c4ad1d1d9a3b697eb0e05eb2;p=scripts.git Removed lame scripts. --- diff --git a/clean.sh b/clean.sh deleted file mode 100755 index b6767a3..0000000 --- a/clean.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -TRASH=$(mktemp -d /tmp/trash.XXXXXX) - -# "pdf:fig" "pdf:png" "pdf:pgm" - -for i in "nav:tex" "snm:tex" "toc:tex" "blg:tex" \ - "idx:tex" "ilg:tex" "ind:tex" "lof:tex" "lot:tex" "lou:tex" \ - "dvi:tex" "log:tex" "aux:tex" "bbl:tex" \ - "ps:tex" "pdf:tex" "out:tex" "tpt:tex" "brf:tex" "vrb:tex" \ - "eps:fig" "eps:png" "eps:pgm" \ - "o:cc" "o:c" ; do - PRODUCED=$(echo $i | cut -f 1 -d:) - SOURCE=$(echo $i | cut -f 2 -d :) - for f in *.$PRODUCED; do - ORIGINAL=${f/.$PRODUCED/.$SOURCE} - if [ -f "${ORIGINAL}" ]; then - # if [ "${f}" -nt "${ORIGINAL}" ]; then - echo "Moving file $f to ${TRASH} ($ORIGINAL exists)" - mv $f ${TRASH} - # else - # echo "File $f is older than $ORIGINAL. Keeping both." - # fi - fi - done -done - -for i in "mozilla.ps" "a.out"; do - if [ -f "$i" ]; then - echo "move $i to ${TRASH}" - mv $i ${TRASH} - fi -done - -for f in $(find -type f -executable); do - if [ -f ${f}.cc ] || [ -f ${f}.c ]; then - echo "Moving $f to ${TRASH} (source code exists)" - mv $f ${TRASH} - fi -done diff --git a/dirtohtml.sh b/dirtohtml.sh deleted file mode 100755 index 82fc1ba..0000000 --- a/dirtohtml.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -function error () { - echo $1 1>&2 - exit 1 -} - -## Header ############################################################ - -cat < - - - - - - - - - - - -EOF - -## Body ############################################################## - -echo "

Directory content

" - -echo - -echo "
"
-
-for d in $(find . -maxdepth 1 -type d -name "[^.]?*" | sort); do
-    echo "${d}"
-
-    # most_recent=$(find ${d} -type f -exec stat --printf="%Y %n\n" '{}' \; | sort | tail -1 | awk '{print $4}')
-
-    # if [[ ${most_recent} ]]; then
-        # date=$(date -r ${most_recent})
-    # else
-        # date=$(date -r ${d})
-    # fi
-
-    # echo "${date} ${d}"
-done
-
-echo "
" - -echo - -## Footer ############################################################ - -cat < - - -EOF - -###################################################################### diff --git a/emacs-cvs-in-debian.sh b/emacs-cvs-in-debian.sh deleted file mode 100755 index 3c5ea25..0000000 --- a/emacs-cvs-in-debian.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -# You need at least the Debian packages: gcc make cvs texinfo -# libx11-dev libxft-dev libgif-dev libjpeg62-dev libpng12-dev -# libtiff4-dev libxpm-dev - -set -e - -DIR=/usr/local/emacs-snapshot - -while [[ $1 ]]; do - - case $1 in - - ################################################################ - - download) - - mkdir -p ${DIR} - - cd ${DIR} - - cvs -z3 \ - -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs \ - co emacs - - ;; - - ################################################################ - - compile) - - cd ${DIR}/emacs/ - - # I do not like gtk and such, hence the very limited - # configuration options. Feel free to add your own. - - ./configure --prefix=${DIR} \ - --with-xpm --with-jpeg --with-tiff --with-png \ - --with-x --with-xft - - make -k bootstrap - make install - - ;; - - ################################################################ - - install) - - if [[ -a /usr/share/emacs-snapshot ]]; then - echo "You have to remove /usr/share/emacs-snapshot." >&2 - exit 1 - fi - - # We do not know the version you downloaded. This ugly - # command will figure it out for you - - SHARE=$(find ${DIR}/share/emacs/ -maxdepth 1 -mindepth 1 -type d \ - | \grep "/[0-9\.]*$") - - if [[ ! -d "${SHARE}" ]]; then - echo "Can not find ${SHARE}, that's weird." >&2 - exit 1 - fi - - ln -s ${SHARE}/ /usr/share/emacs-snapshot - - for p in emacs ctags etags emacsclient ebrowse; do - # Install the binary as a link in /usr/bin - ln -s ${DIR}/bin/$p /usr/bin/$p-snapshot - # Tell the Debian system that the binary can be used - # as an alternative version - update-alternatives \ - --install /usr/bin/$p $p /usr/bin/$p-snapshot 23 - # Tell the Debian system that that new version should - # be used as default - update-alternatives \ - --set $p /usr/bin/$p-snapshot - done - - mkdir -p /etc/emacs-snapshot/site-start.d - - # Compile and install for that version of emacs all the - # emacs packages installed as Debian packages (vm, bbdb, - # etc.) - /usr/lib/emacsen-common/emacs-install emacs-snapshot - - ;; - - ################################################################ - - deinstall) - - # Remove that version of emacs from the list of versions - # for which Debian emacs-related packages should be - # compiled - /usr/lib/emacsen-common/emacs-remove emacs-snapshot - - rm -rf /etc/emacs-snapshot - - # Remove the alternatives - for p in emacs ctags etags emacsclient ebrowse; do - update-alternatives --remove $p /usr/bin/$p-snapshot - rm /usr/bin/$p-snapshot - done - - rm /usr/share/emacs-snapshot - ;; - - ################################################################ - - remove) - - rm -rf ${DIR} - - ;; - - ################################################################ - - *) - - echo "$0 " >&2 - exit 1 - - ;; - - esac - - shift 1 - -done diff --git a/gma.sh b/gma.sh deleted file mode 100755 index d914893..0000000 --- a/gma.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -set -e - -function usage () { - echo "gma.sh [--body] [--nospam] [--subject|--from|--to|--fromto|--sender] []" -} - -RESULT_MBOX="/tmp/gma" -KEEP_SPAM=1 - -if [[ -z "${MAIL_ARCHIVE_DIR}" ]]; then - echo "Undefined \$MAIL_ARCHIVE_DIR" >&2 - exit 1 -fi - -if [[ $(which ionice) ]]; then - IONICE="ionice -c3" -else - IONICE="" -fi - -HEADER_ONLY="-H" - -while [[ $1 ]]; do - - case $1 in - - "--help"|"-h") - usage - exit 0 - ;; - - "--body") - HEADER_ONLY="" - ;; - - "--intense") - IONICE="" - ;; - - "--nospam") - KEEP_SPAM=0 - ;; - - "--from") - RE_PREFIX="^From:.*" - ;; - - "--to") - RE_PREFIX="^To:.*" - ;; - - "--fromto") - RE_PREFIX="^(From|To):.*" - ;; - - "--sender") - RE_PREFIX="^Sender:.*" - ;; - - "--subject") - RE_PREFIX="^Subject:.*" - ;; - - *) - if [[ ${PATTERN} ]]; then - # If we already have the pattern to match in the - # message, get the new argument as a pattern for the - # filename - if [[ ${FILE_PATTERN} ]]; then - usage - exit 1 - else - FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${1}/*/*" - SIZE_FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${1}" - fi - else - PATTERN=$1 - fi - ;; - esac - shift -done - -if [[ -z "${PATTERN}" ]]; then - usage - exit 1 -fi - -[[ ${FILE_PATTERN} ]] || FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*" -[[ ${SIZE_FILE_PATTERN} ]] || SIZE_FILE_PATTERN="${MAIL_ARCHIVE_DIR}" - -SIZE=$(\dus ${SIZE_FILE_PATTERN} | cut -f 1 -d" ") - -echo "Looking for ${RE_PREFIX}${PATTERN}" -echo " in ${FILE_PATTERN}" -echo " writing result in ${RESULT_MBOX}" - -if [[ ${KEEP_SPAM} == "1" ]]; then - - ${IONICE} cat ${FILE_PATTERN} \ - | pv -s ${SIZE} -p -t -e - \ - | mboxgrep ${HEADER_ONLY} -i "${RE_PREFIX}${PATTERN}" > ${RESULT_MBOX} - -else - - ${IONICE} cat ${FILE_PATTERN} \ - | pv -s ${SIZE} -p -t -e - \ - | mboxgrep ${HEADER_ONLY} -i "${RE_PREFIX}${PATTERN}" \ - | mboxgrep ${HEADER_ONLY} -v '^Subject:.*SPAM' > ${RESULT_MBOX} - -fi - -echo "Found "$(grep ^"From " ${RESULT_MBOX} | wc -l)" messages." diff --git a/hotspot.sh b/hotspot.sh deleted file mode 100755 index a8a27ae..0000000 --- a/hotspot.sh +++ /dev/null @@ -1,355 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -INTERFACE=${WIFI_INTERFACE} - -[[ ${INTERFACE} ]] || INTERFACE=wlan0 - -MTU=512 - -SCAN_OUTPUT=$(mktemp /tmp/scanresult.XXXXXX) -SHOW_CLOSED=0 - -###################################################################### - -VT_CURSOR_OFF=$'\033[?25l' -VT_CURSOR_ON=$'\033[?25h' - -VT_RESET=$'\033[0m' -VT_BOLD=$'\033[1m' -VT_UNDERLINE=$'\033[4m' -VT_BLINK=$'\033[5m' - -VT_BLACK_FG=$'\033[30m' -VT_RED_FG=$'\033[31m' -VT_GREEN_FG=$'\033[32m' -VT_YELLOW_FG=$'\033[33m' -VT_BLUE_FG=$'\033[34m' -VT_MAGENTA_FG=$'\033[35m' -VT_CYAN_FG=$'\033[36m' -VT_WHITE_FG=$'\033[37m' - -VT_BLACK_BG=$'\033[40m' -VT_RED_BG=$'\033[41m' -VT_GREEN_BG=$'\033[42m' -VT_YELLOW_BG=$'\033[43m' -VT_BLUE_BG=$'\033[44m' -VT_MAGENTA_BG=$'\033[45m' -VT_CYAN_BG=$'\033[46m' -VT_WHITE_BG=$'\033[47m' - -###################################################################### - -function cleanup-before-quit () { - echo ${VT_CURSOR_ON} - stty "$stty_state" - rm -f ${SCAN_OUTPUT} - if [[ "${interface_was_up}" == "" ]]; then - echo "The interface was down." - ifconfig ${INTERFACE} down - fi -} - -function sigint-handler () { - cleanup-before-quit - echo "Interrupted" - exit 0 -} - -function scan () { - echo - echo " Scanning ..." - iwconfig ${INTERFACE} ap off essid "" - iwlist ${INTERFACE} scan | \ - sed -e "s/^[\t ]*//" | grep ^"Cell\|ESSID\|Quality\|Encryption" | \ - sed \ - -e "s/Cell [0-9]* - Address: \([0-9]*\)/AP,\1/" \ - -e "s/^ *ESSID:\\\"\([^\\\"]*\)\\\".*$/ESSID,\1/" \ - -e "s/Quality=\([0-9]*\).*$/QUALITY,\1/" \ - -e "s/Encryption key:/ENCRYPTION,/" | \ - awk 'BEGIN { FS="," } - { - if($1 == "ESSID") { essid=$2 } - else if($1 == "AP") { ap=$2 } - else if($1 == "QUALITY") { quality=$2; } - else if($1 == "ENCRYPTION") { - if($2 == "off") { - open=" " - printf("%d,%s,%s,%s\n",quality,open,essid,ap); - } else { - if('${SHOW_CLOSED}') { - open="(closed)" - printf("%d,%s,%s,%s\n",quality,open,essid,ap); - } - } - } - }' | \ - sort -rn > ${SCAN_OUTPUT} - - number_of_aps=$(wc -l ${SCAN_OUTPUT} | awk '{print $1}') - - chmod a+rw ${SCAN_OUTPUT} -} - -function redisplay () { - clear - - echo - echo -n " ${VT_UNDERLINE}Hotspot selection${VT_RESET}" - if [[ $SHOW_CLOSED == 0 ]]; then - echo " (show only open networks)" - else - echo - fi - echo - echo " [s,r] scan [m] switch the free-only view and scan [q] quit" - echo " [e] select essid + dhcp [a] selects essid/ap + dhcp [k] kill dhcp and quit" - echo - - for i in $(ifconfig -s | grep -E -v ^lo\|Iface\|wmaster | awk '{print $1}'); do - echo " Warning: $i is up" - done - echo - - if [[ ${number_of_aps} == "0" ]]; then - echo " ${VT_RED_FG}${VT_BOLD}No access point detected.${VT_RESET}" - else - - awk < ${SCAN_OUTPUT} 'BEGIN { nb=1; FS="," } - { - if(nb == '$current_ap') { - printf(" =>"); - } else { - printf(" "); - } - if($2 == "(closed)") { - printf("'${VT_RED_FG}'"); - printf("% 3s %s \"%s\" %s'${VT_RESET}'\n", $1, $2, $3, $4); - } else { - printf("'${VT_GREEN_FG}'"); - printf("% 3s %s \"%s\" %s'${VT_RESET}'\n", $1, $2, $3, $4); - } - nb=nb+1; - }' - fi -} - -function get-selected-essid-ap () { - cat ${SCAN_OUTPUT} | \ - awk 'BEGIN { nb=1; FS="," } - { - if(nb == '$current_ap') { - printf("%s,%s\n", $3, $4); - } - nb=nb+1; - }' -} - -function kill-dhcp () { - PID=$(pidof dhclient) - if [[ ${PID} ]]; then - echo "Killing dhclient" - dhclient -x ${INTERFACE} - fi -} - -###################################################################### - -function process-key () { - - case $1 in - e) # Selects essid + dhcp - SELECTED=$(get-selected-essid-ap) - ESSID=$(echo ${SELECTED} | cut -f 1 -d,) - echo "Running DHCP on ${INTERFACE} for ESSID \"${ESSID}\"." - iwconfig ${INTERFACE} ap auto essid "${ESSID}" - kill-dhcp - echo - dhclient ${INTERFACE} - # if [[ $? == 0 ]]; then - # iwconfig ${INTERFACE} > ~/.hotspot-ap - # fi - ifconfig ${INTERFACE} mtu ${MTU} - interface_was_up=1 - cont=0 - ;; - - "return"|a) # Selects essid/ap + dhcp - SELECTED=$(get-selected-essid-ap) - ESSID=$(echo ${SELECTED} | cut -f 1 -d,) - AP=$(echo ${SELECTED} | cut -f 2 -d,) - echo "Running DHCP on ${INTERFACE} for ESSID \"${ESSID}\" and AP ${AP}." - iwconfig ${INTERFACE} ap ${AP} essid "${ESSID}" - kill-dhcp - echo - dhclient ${INTERFACE} - # if [[ $? == 0 ]]; then - # iwconfig ${INTERFACE} > ~/.hotspot-ap - # fi - ifconfig ${INTERFACE} mtu ${MTU} - interface_was_up=1 - cont=0 - ;; - - k) # kill dhcp - echo "Killing DHCP and bringing down ${INTERFACE}." - kill-dhcp - ifconfig ${INTERFACE} down - cont=0 - ;; - - r|s) # re-scanning the access points - scan - redisplay - ;; - - m) # Switching the mode to show the protected spots - SHOW_CLOSED=$((1-SHOW_CLOSED)) - scan - redisplay - ;; - - "down"|n) - current_ap=$((current_ap+1)) - if [[ $current_ap -gt $number_of_aps ]]; then - current_ap=$number_of_aps - fi - redisplay - ;; - - "up"|p) - current_ap=$((current_ap-1)) - if [[ $current_ap -lt 1 ]]; then - current_ap=1 - fi - redisplay - ;; - - "esc-esc"|q) - echo " Quit." - cont=0 - ;; - - *) - ;; - esac -} - -###################################################################### -## The main - -if [[ $1 == "-k" ]]; then - echo "Killing DHCP and bringing down ${INTERFACE}." - kill-dhcp - ifconfig ${INTERFACE} down - exit 1 -fi - -trap cleanup-before-quit EXIT - -stty_state=$(stty -g) - -trap sigint-handler SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM - -stty -echo -icrnl -icanon -xcase min 1 time 0 - -echo ${VT_CURSOR_OFF} - -current_ap=1 -cont=1 -current_keymap=default - -interface_was_up=$(ifconfig | grep ${INTERFACE}) - -ifconfig ${INTERFACE} up - -scan - -redisplay - -while [[ ${cont} == 1 ]]; do - - CHAR=$(dd bs=1 count=1 2>/dev/null) - - case ${current_keymap} in - default) ################################################## - case ${CHAR} in - - [a-z]) - process-key ${CHAR} - ;; - - " ") - process-key "return" - ;; - - "") - process-key "down" - ;; - - "") - process-key "up" - ;; - - "") #$'\033'") - current_keymap=escape - ;; - - *) - ;; - esac - ;; - - escape) ################################################## - case ${CHAR} in - "$'\033'") - process-key "esc-esc" - ;; - "[") - current_keymap=cursor - ;; - *) - current_keymap=default - ;; - esac - ;; - - cursor) ################################################## - - current_keymap=default - - case ${CHAR} in - A) - process-key "up" - ;; - B) - process-key "down" - ;; - *) - ;; - esac - ;; - - *) - echo "Unknown keymap. This is an internal and weird bug." - cont=0 - ;; - esac - -done diff --git a/html2text.sh b/html2text.sh deleted file mode 100755 index fe10cc0..0000000 --- a/html2text.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -set -e - -echo "(From html)" -echo - -elinks -no-numbering -no-references -dump -dump-width 80 -dump-charset utf-8 | \ - sed -e "s/\[IMG\]//g" -e "s/^[ \t]*$//" -e "s/^ //" | \ - awk '/^$/{ if (! blank++) print; next } { blank=0; print }' - diff --git a/picstohtml.sh b/picstohtml.sh deleted file mode 100755 index 70310c2..0000000 --- a/picstohtml.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -function error () { - echo $1 1>&2 - exit 1 -} - -###################################################################### -# Create the directories - -if [[ -z $1 ]] || [[ -z $2 ]]; then - echo "$0 " - exit 1 -fi - -if [[ ! -d $1 ]]; then - echo "Can not find directory $1" - exit 1 -fi - -mkdir $2 || error "Can not create $2." -mkdir $2/pics || error "Can not create $2/pics" -mkdir $2/thumbs || error "Can not create $2/thumbs" - -###################################################################### -# Generate the html header - -cat > $2/index.html < - - - - - - - - - - - -EOF - -###################################################################### -# Generate the thumbnails, html content and copy the images - -for i in $(find $1 -type f | sort); do - FILENAME=$(basename $i) - convert 2> /dev/null -geometry 180x120 $i $2/thumbs/${FILENAME}.jpg - - if [[ $? == 0 ]]; then - echo "Copying ${FILENAME}" - cp $i $2/pics/${FILENAME} - echo "" >> $2/index.html - else - echo "Ignoring $i (not an image?)" - fi - -done - -###################################################################### -# Generate the footer of the html file - -cat >> $2/index.html < - - -EOF - -###################################################################### diff --git a/print.sh b/print.sh deleted file mode 100755 index c3815f4..0000000 --- a/print.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -set -e - -# $Id: print.sh,v 1.19 2006-11-10 15:53:23 fleuret Exp $ - -if [ ! "$*" ]; then - echo "Need filenames to print!" - exit 1 -fi - -tmp=$(mktemp /tmp/print.ps.XXXXXX) -opts="" -printing_cmd="lpr" - -function cleanup-before-exit () { - rm ${tmp} -} - -trap cleanup-before-exit EXIT - -for arg in "$@"; do - - if [ "${arg}" == "-h" ] || [ "${arg}" == "--help" ]; then - - # The help option - - echo $(basename $0)" [ ... ] [[ ... ] ... ]" - echo - echo "A dumb printing utility. Options:" - echo - echo "-2pp two pages per page" - echo "-4pp four pages per page" - echo "-8pp eight pages per page" - echo "-gv displays the result with gv instead of printing" - echo "-stdout send the result to the standard output" - echo "-P uses instead of $PRINTER" - echo - echo "Contact " - echo "Version \$Id: print.sh,v 1.19 2006-11-10 15:53:23 fleuret Exp $" - - exit 0 - - elif [[ ${arg} == "-"* ]]; then - - # else, if it starts with '-' it is an option - - opts="${opts} ${arg}" - - else - - # else, it is a filename to print - - if [ -e "${arg}" ]; then - - TYPE=$(file -L "${arg}") - - noprint="" - - case $TYPE in - - *"image data"*) - convert "${arg}" ps:${tmp} - ;; - - *"TeX DVI"*) - dvips -o ${tmp} "${arg}" - ;; - - *"FIG image"*) - fig2dev -L ps "${arg}" > ${tmp} - ;; - - *"PostScript"*) - cp "${arg}" ${tmp} - ;; - - *"PDF"*) - pdf2ps "${arg}" ${tmp} - ;; - - *" text"*) - # a2ps -B -R --columns=1 -f 8 -o ${tmp} "${arg}" - # if isutf8 -q ${tmp}; then - # echo "Can not print uf8 text." - # exit 1 - # else - a2ps --media=A4 --user-option=lp -o ${tmp} "${arg}" - # fi - ;; - - *"gzip compressed"*) - echo "Unzipping " - zcat "${arg}" > ${tmp} - noprint=1 - $0 ${opts} ${tmp} - ;; - - *) - echo "Unable to handle type \"$TYPE\""; noprint=1 - ;; - - - esac - - if [ ! "$noprint" ]; then - - # We apply all the filters seen up to now - - for f in ${opts}; do - case $f in - -2pp) - tmp2=$(mktemp /tmp/filter.ps.XXXXXX) - psnup -d0 -m5 -2 < ${tmp} > ${tmp2} - mv ${tmp2} ${tmp} - ;; - -4pp) - tmp2=$(mktemp /tmp/filter.ps.XXXXXX) - psnup -d0 -m5 -4 < ${tmp} > ${tmp2} - mv ${tmp2} ${tmp} - ;; - -8pp) - tmp2=$(mktemp /tmp/filter.ps.XXXXXX) - psnup -d0 -m5 -8 < ${tmp} > ${tmp2} - mv ${tmp2} ${tmp} - ;; - -gv) - printing_cmd="gv" - ;; - - -stdout) - printing_cmd="cat" - ;; - - -P*) - printing_cmd="lpr" - PRINTER=$(echo $f | sed -e s/^-P//) - if [[ -z "$PRINTER" ]]; then - echo "Error in the printer name. Use -P with no space." - lpstat -a - exit 1 - else - echo "Using printer \"$PRINTER\"" - fi - ;; - *) - echo "Unknown option $f" - exit 1;; - esac - done - - if [[ "$printing_cmd" == "lpr" ]]; then - echo "Printing on printer '$PRINTER'" - show_queue=1 - fi - - ${printing_cmd} ${tmp} - - fi - - else - - echo "Can not find file ${arg}" - - fi - - fi - -done - -if [[ ${show_queue} ]]; then - lpq -fi - -exit 0 diff --git a/sshmount.sh b/sshmount.sh deleted file mode 100755 index 3cd7f51..0000000 --- a/sshmount.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -set -e - -hostname=$1 -remotepath=$2 -localpath=/mnt/sshfs/${hostname}/${remotepath} - -if [[ $1 == "--help" ]] || [[ $1 == "-h" ]]; then - cat < []] - -Mount the remote path on /mnt/sshfs// if it is -not already mounted. Umount it otherwise. - -If no argument is provided, tries to umount all the mounted sshfs -volumes. -EOF - - exit 0 -fi - -if [[ $1 ]]; then - if [[ $(mount | grep ${hostname}:${remotepath}) ]]; then - fusermount -u ${localpath} - echo "sshfs umounted from ${localpath}." - else - mkdir -p ${localpath} - sshfs -o idmap=user -C ${hostname}:${remotepath} ${localpath} - echo "Remote ${hostname}:${remotepath} mounted on ${localpath}." - fi -else - for v in $(mount | grep fuse.sshfs | cut -f 3 -d' '); do - fusermount -u ${v} - echo "sshfs umounted from ${v}" - done -fi diff --git a/viewer.sh b/viewer.sh deleted file mode 100755 index 98682d4..0000000 --- a/viewer.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/sh - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -set -e - -function getgeometry () { - XSETUP="/tmp/xsetup" - - if [[ -f "${XSETUP}" ]]; then - - ACTIVE_SCREEN_GEOMETRY=($(awk '{ - if(0>= $5 && 0 < $5+$3) { print $2" "$3" "$4" "$5 } - }' < ${XSETUP})) - - ACTIVE_WIDTH=${ACTIVE_SCREEN_GEOMETRY[0]} - ACTIVE_HEIGHT=${ACTIVE_SCREEN_GEOMETRY[1]} - ACTIVE_X=${ACTIVE_SCREEN_GEOMETRY[2]} - ACTIVE_Y=${ACTIVE_SCREEN_GEOMETRY[3]} - - GEOMETRY="${ACTIVE_WIDTH}x${ACTIVE_HEIGHT}+${ACTIVE_X}+${ACTIVE_Y}" - fi -} - -# This is my universal file viewer - -# If no argument is given, we pick the most recent file - -if [[ ! "$1" ]]; then - file=$(\ls -tQ | head -1 | sed -e s/\"//g) - echo "Most recent is ${file}" - $0 "${file}" - exit 0 -fi - -# If there were arguments, we loop through them - -echo "Viewing $@" - -while [[ "$1" ]]; do - - file="$1" - - # file=$(\ls -tQd $1 | head -1 | sed -e s/\"//g) - - # if [[ ! -a "${file}" ]]; then - # echo "Can not find file $1" - # exit 1 - # fi - - type=$(file -L "${file}") - - case ${type} in - - *"FIG image text"*) - echo "${file}" - temp=$(mktemp /tmp/view.XXXXXX) - fig2dev -L pdf "${file}" ${temp} - # xpdf -g 800x600+8+8 ${temp} - getgeometry - xpdf -g ${GEOMETRY} ${temp} - rm ${temp} - ;; - - *"image"*) - echo "${file}" - # feh -g 800x600 "${file}" - getgeometry - feh -g ${GEOMETRY} "${file}" - ;; - - *"TeX DVI"*) - echo "${file}" - xdvi "${file}" - ;; - - # *"FIG image"*) - # echo "${file}" - # xfig "${file}" - # ;; - - *"PostScript"*) - echo "${file}" - gv "${file}" - ;; - - *"PDF"*) - echo "${file}" - # xpdf -g 800x600+8+8 "${file}" - getgeometry - xpdf -g ${GEOMETRY} "${file}" - ;; - - *"WAVE audio"*) - echo "${file}" - esdplay "${file}" - ;; - - *"MP3"*|*"MPEG"*|*"movie"*|*"video"*|*"AVI"*|*"Microsoft ASF"*) - mplayer -quiet "${file}" - ;; - - *" text"*) - HEIGHT=$(stty size | awk '{print $1}') - if [[ $(wc -l "${file}" | cut -f 1 -d' ') -gt $((HEIGHT-2)) ]]; then - less "${file}" - else - cat "${file}" - fi - ;; - - *"tar archive"*) - tar ztf "${file}" - ;; - - *"Microsoft Word Document"*) - antiword "${file}" | less - ;; - - *"directory"*) - echo ""${file}":"; ls -lt "${file}" - ;; - - *"gzip compressed"*) - temp=$(mktemp /tmp/view.XXXXXX) - echo "Decompressing to ${temp}" - zcat "${file}" > ${temp} - $0 ${temp} - echo "Removing ${temp}" - rm ${temp} - ;; - - *) - echo "Unable to handle ${type}" - ;; - - esac - - shift - -done diff --git a/withlock.sh b/withlock.sh deleted file mode 100755 index 980deb1..0000000 --- a/withlock.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -######################################################################### -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the version 3 of the GNU General Public License # -# as published by the Free Software Foundation. # -# # -# 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, see . # -# # -# Written by and Copyright (C) Francois Fleuret # -# Contact for comments & bug reports # -######################################################################### - -# This command allows to call another command with a lockfile to avoid -# concurrent executions for the same user. - -set -e - -if [[ ! $1 ]]; then - echo "withlock.sh [command args]" - exit 1 -fi - -LOCKFILE=/tmp/lock$(which $1 | sed -e "s:/:-:g").${USER} - -(set -C && : > ${LOCKFILE}) 2> /dev/null - -if [ $? != "0" ]; then - echo "Lockfile ${LOCKFILE} exists." >&2 - exit 1 -fi - -trap 'rm ${LOCKFILE}' EXIT - -$*