Content tagged as bash

awstatic.sh - Generate static awstats reports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
# samu 2010-02-23
 
STATIC_DEST="/var/www/awstats/static"
 
cat > "$STATIC_DEST/index.html" << EOF
<html><head><title>AWSTATS - Static</title></head><body>
<h1>AWSTATS - Static Statistics</h1>
<ul>
EOF
 
for conf in $( ls /etc/awstats/ | grep "^awstats\..*\.conf\$" | sed "s/^awstats\.\(.*\).conf\$/\1/" ); do
  echo "Generating static pages for $conf ..."
  if [ ! -e "${STATIC_DEST}/${conf}" ]; then
    mkdir -p "${STATIC_DEST}/${conf}"
  fi

drupal-crons.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
#
# Drupal sites cronjob runner. Useful to be put into crontab.
# samu 2009-12-06
#
 
## --- Configuration ---
CONF_SITES="/usr/local/etc/drupal-sites" # sites list
CONF_LOGDIR="/var/log/drupal-cron" # logs dir
## --- End Config ---
 
# load sites list, stripping lines that are empty or starting by #
SITES="$(cat "$CONF_SITES" |grep -ve "^$\|^[^A-Za-z0-9]*#")"
 
# create log directory if not exists
if [ !

twittit.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
 
#
# Send to twitter a message.
#
# Copyright (C) 2009 - Samuele ~redShadow~ Santi - Under GPL v3
# Please visit : http://www.hackzine.org
#
# Just run this script to be asked for a message to publish on your twitter.
# Twitter login informations are asked at the first run of the script, and
# then saved into ~/.twitter-login for future use.
#
 
 
if [ -e ~/.twitter-login ]; then
  TWITTLOGIN="$( cat ~/.twitter-login )"
else
  TWITTLOGIN="$( Xdialog --stdout --title "Twittit" --inputbox "Insert twitter login:" 0 0 "login:pass" )"
  echo "$TWITTLOGIN" > ~/.twitter-lo

autosnap.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
 
#
# Auto-screenshot taker
#
# Uses xsnap and ssh to take snapshot of a region or window
# and upload it to a remote server to quickly share it.
# 
# Copyright (C) 2009  Samuele ~redShadow~ Santi - Under GPL v3
# Please visit : http://www.hackzine.org
#
 
# TODO find a better way to handle ssh key request
# we assume that you're using ssh-agend and have the key registered
# else, there could be some problems / unknown behaviours
 
# Also, on Xfce, adding a launcher with "Run in terminal" flag on
# does the job since terminal is launched in background..
 
# Or, there

SVG Image Tiler

Inkscape logo

Ecco qua uno scriptino bash che ho realizzato per "ritagliare" comodamente delle immagini da un file SVG e convertirle automaticamente in PNG.

svgtiler.sh

Il tutto in BashScript, appoggiandomi su Inkscape..
Il funzionamento è molto semplice: vengono definite le dimensioni della "griglia", altezza e larghezza delle tile e numero in verticale e orizzontale. quindi, definiti gli id delle tile interessanti (specificati come righe/colonne) lo script procede chiamando inkscape per esportare le parti utili dell'immagine in un dato percorso di destinazione.

svgtiler.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
 
#
# SVG Image Tiler - transform SVG images into PNG tiles
# Copyright (C) 2009  Samuele ~redShadow~ Santi
#
# 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 3 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.

clean-filenames.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
#
# FileName cleaner - v0.1
# Replaces all special chars from filenames, allowing only use of:
# letters, numbers, underscore, dash, dot.
# Converts also UTF-8 characters to their "similar" ASCII-128 char.
# 
# (c)2009 Samuele ~redShadow~ Santi - <redshadow@hackzine.org> - Under GPL
#
# TODO find a way to remove in-name extra dots.
#       We don't just need to leave the last dot, since there are files
#       such as .tar.gz and .tar.bz2 with "double-extension"
#
# TODO make it work recursively on dirs (..a bit dangerous..)
# 
# ATTENTION:  Do NOT use on complex p

Pulitura nomi file

Terminal-01

Quante volte capita di avere a che fare con file di varia provenienza a cui l'autore si è sbizzarrito a dare nomi assurdi contenenti, oltre a spazi, perfino caratteri in utf-8 ecc..?

Questo script serve per cercare di rimettere un po' a posto le cose, sostituendo spazi con underscore, lettere accentate con lettere "normali", ecc..

Drupal module creation script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
 
#
# Script to create Drupal Modules
# by Samuele ~redShadow~ Santi
# http://hackzine.org
#
 
if [ "$1" != "" ]; then
  modname="$1"
else
  echo "Usage: $0 <modulename> [<core>]";
  exit 0
fi
 
 
if [ "$2" != "" ]; then
  dcore="$2"
else
  dcore="6.x"
fi
 
 
gpl="
 /*
  * $modname - A Drupal $dcore module
  * Copyright (C) `date +%Y`  ${USER}@${HOSTNAME}
  *
  * 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 3 of th

Archiver Bash Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
 
#
#     archive.sh - A fast archiver, useful for making snapshots
#     Copyright (C) 2008  Samuele ~redShadow~ Santi
#     http://hackzine.org
#
#     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 3 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 

Altri due script utili..

Terminal-01

Pubblico anche altri due script comodi che ho realizzato:

archive.sh
Scriptino bash per creare velocemente archivi di backup di una cartella, includendo nel nome del file data e ora
http://doku.hackzine.org/scripts/archive

bulkchmod.sh
Script per cambiare velocemente e ricorsivamente i permessi su file/cartelle con un comando del tipo
bulkchmod 755 644 /path/to/files
http://doku.hackzine.org/scripts/bulkchmod

Who Am I?

~redShadow~ A.K.A. Samuele Santi is an Italian Open Source developer, currently working as a freelance developer, mainly in the web applications sector. Favourite programming languages: PHP and, of course, Python!

aoe (1) doku (1) blender (3) alcool (1) aircrack (1) cocktails (1) 3d (3) e-mail (2) cars (1) apt (1) curl (1) algorythms (1) cartoons (1) address book (2) cryptography (1) contact manager (1) caos (1) 2v (1) database (3) circuits (1) arduino (1) bash (11) Drupal (21) como lake rovers (1) audio (1) backup (3) development (11) Drupal Forms (1) debug (1) blogroll (7) C++ (2) debian (1) dmcrypt (1) awstats (3) citroen (1) code (3) documentation (2) archive (1) apache (1) camera mia (1)