mercredi 26 novembre 2014

Commandes shell Linux avancées

Actions sur fichiers:

Faire un "svn delete" de tous les fichiers supprimés alors qu'ils sont référencés sur SVN: 

Lorsque des fichiers sous SVN ont été supprimés sans avoir utilisé la commande "svn delete", il n'est pas possible de commiter leur suppression. Donc pour ne plus avoir d'erreur SVN, il suffit de lancer cette commande:
svn status | grep '!' | sed "s/[^\w]* //"  | xargs  -I{} svn delete {}


Commiter un par un des fichiers supprimés par "svn delete"

Cela peut être utile si vous tombez en gateway time-out
svn status | grep 'D' | sed "s/[^\w]* //"  | xargs  -I{} svn ci -m "purge" {}


Déplacer des fichiers en fonction de leur contenu:

Pour déplacer des fichiers contenant une certaine chaîne de caractères (exemple ici avec "Access denied for user") vers un répertoire (exemple ici avec "/tmp/access_denied/"):
grep -rli "Access denied for user" *  | xargs  -I{} mv {} /tmp/access_denied/


Pour l'infogérance de votre parc informatique, contactez ASPerience au 09 80 08 25 47

Installation bacula par les sources sur ubuntu 12.04

Compilation bacula

Installation Qt 4.8.4: qt-everywhere-opensource-src-4.8.6.tar.gz

DAEMON_USER=bacula
DAEMON_GROUP=bacula
DIRECTOR_DAEMON_USER=${DAEMON_USER}
STORAGE_DAEMON_USER=${DAEMON_USER}
FILE_DAEMON_USER=root
STORAGE_DAEMON_GROUP=${DAEMON_GROUP}
WORKING_DIR=/var/lib/bacula
BACULA-DIRECTOR=asperience1

export LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.8.6/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/Trolltech/Qt-4.8.6/bin:$PATH

./configure   --prefix=/var/lib/bacula \
  --sbindir=/var/lib/bacula \
  --with-sbin-perm=755 \
  --sysconfdir=/var/lib/bacula/config \
  --with-archivedir=/var/lib/bacula/storage \
  --with-scriptdir=/var/lib/bacula/scripts \
  --with-plugindir=/var/lib/bacula/plugins \
  --with-working-dir=/var/lib/bacula \
  --with-pid-dir=/var/lib/bacula \
  --with-bsrdir=/var/lib/bacula \
  --with-logdir=/var/log/bacula \
  --with-subsys-dir=/var/lock \
  --disable-acl \
  --enable-smartalloc \
  --enable-conio \
  --enable-readline \
  --enable-batch-insert \
  --enable-dynamic-cats-backends \
  --enable-bat \
  --enable-traymonitor \
  --enable-xattr \
  --enable-scsi-crypto \
  --enable-lockmgr \
  --enable-ndmp \
  --enable-ipv6 \
  --with-mysql \
  --with-tcp-wrappers \
  --with-openssl \
  --with-systemd \
  --with-python \
  --with-dir-user=${DIRECTOR_DAEMON_USER} \
  --with-dir-group=${DAEMON_GROUP} \
  --with-sd-user=${STORAGE_DAEMON_USER} \
  --with-sd-group=${STORAGE_DAEMON_GROUP} \
  --with-fd-user=${FILE_DAEMON_USER} \
  --with-fd-group=${DAEMON_GROUP} \
  --with-dir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
  --with-fd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
  --with-sd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
  --with-mon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
  --with-mon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
  --with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
  --with-basename=${BACULA-DIRECTOR} \
  --with-hostname=${BACULA-DIRECTOR} \
  --enable-includes


Ajouter le user et le groupe bacula

Installation bacula

make
sudo make install

Création de la base:
./create_mysql_database -u root -p

Population de la base:
./make_mysql_tables -u root -p

Assignation des privilèges:
./grant_mysql_privileges -u root -p


Installation bareos par les sources sur Ubuntu 12.04

Compilation bareos

DAEMON_USER=bareos
DAEMON_GROUP=bareos
DIRECTOR_DAEMON_USER=${DAEMON_USER}
STORAGE_DAEMON_USER=${DAEMON_USER}
FILE_DAEMON_USER=root
STORAGE_DAEMON_GROUP=${DAEMON_GROUP}
WORKING_DIR=/var/lib/bareos

./configure   --prefix=/usr \
  --sbindir=/usr/sbin \
  --with-sbin-perm=755 \
  --sysconfdir=/etc/bareos \
  --with-archivedir=/var/lib/bareos/storage \
  --with-scriptdir=/usr/lib/bareos/scripts \
  --with-plugindir=/usr/lib/bareos/plugins \
  --with-working-dir=/var/lib/bareos \
  --with-pid-dir=/var/lib/bareos \
  --with-bsrdir=/var/lib/bareos \
  --with-logdir=/var/log/bareos \
  --with-subsys-dir=/var/lock \
  --enable-smartalloc \
  --disable-conio \
  --enable-readline \
  --enable-batch-insert \
  --enable-dynamic-cats-backends \
  --enable-acl \
  --enable-bat \
  --enable-traymonitor \
  --enable-xattr \
  --enable-scsi-crypto \
  --enable-ndmp \
  --enable-ipv6 \
  --with-postgresql \
  --with-mysql \
  --with-sqlite3 \
  --with-tcp-wrappers \
  --with-openssl \
  --with-dir-user=${DIRECTOR_DAEMON_USER} \
  --with-dir-group=${DAEMON_GROUP} \
  --with-sd-user=${STORAGE_DAEMON_USER} \
  --with-sd-group=${STORAGE_DAEMON_GROUP} \
  --with-fd-user=${FILE_DAEMON_USER} \
  --with-fd-group=${DAEMON_GROUP} \
  --with-dir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
  --with-fd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
  --with-sd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
  --with-mon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
  --with-mon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
  --with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
  --with-basename="XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX" \
  --with-hostname="XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX" \
  --enable-includes

Ajouter le user et le groupe bareos


Installation bareos

make
sudo make install

Puis installation de la base:
http://doc.bareos.org/master/html/bareos-manual-main-reference.html#QQ2-1-41