Saturday, October 25, 2008

#!/bin/sh

##################################################
## a simple script which sends an email ##
## every monday/thursday when week number ##
## is even. when week number is odd, email ##
## is being sent every tuesday/friday. ##
##################################################

WEEK_MT=0
WEEK_TF=0
DOTW=`date +'%u'`
WN=`date +'%V'`
SUBJECT="some subject"
MAILTO="someone@somewhere"

if [ $(($WN % 2)) -eq 0 ]; then
WEEK_MT=1
else
WEEK_TF=1
fi

sndmail () {
if [ $HRS == 1400h ]; then
NHRS="1300h"
else
NHRS="1400h"
fi
touch emessage.txt
echo "meeting today at $HRS." > emessage.txt
echo "" >> emessage.txt
echo "next meeting on $NDAY at $NHRS." >> emessage.txt
echo "" >> emessage.txt
echo "###############################################################" >> emessage.txt
echo "# more text text text text text text text text text t #" >> emessage.txt
echo "###############################################################" >> emessage.txt
cat emessage.txt | mailx -s "$SUBJECT" $MAILTO
rm emessage.txt
}


if [ $WEEK_MT -eq 1 ] && [ $DOTW -eq 1 ]; then
HRS=1400h
NDAY=Thursday
sndmail
fi

if [ $WEEK_MT -eq 1 ] && [ $DOTW -eq 4 ]; then
HRS=1300h
NDAY=Tuesday
sndmail
fi

if [ $WEEK_TF -eq 1 ] && [ $DOTW -eq 2 ]; then
HRS=1400h
NDAY=Friday
sndmail
fi

if [ $WEEK_TF -eq 1 ] && [ $DOTW -eq 5 ]; then
HRS=1300h
NDAY=Monday
sndmail
fi

exit 0

Monday, October 06, 2008

securing the repo where:
A: deb repo
B: rpm repo
C: main repo (rpm and deb)

A:
create keys:gpg --gen-key
NAME=uid without . get it using gpg --list-keys
modify $REPO_HOME/conf/distributions so it contains following line:
SignWith=NAME
sign (and add to the repository) the package: reprepro --ask-passphrase -A ARCH -Vb $REPO_HOME CODENAME some-package.deb
ARCH=i386, all, amd64..
CODENAME=check conf/distributions for this

export public key: gpg --export -a 'NAME' > export-file-of-public-key
..and secret key: gpg --export-secret-keys > export-file-of-secret-key

copy the exported files to B: scp...........

add following line to conf/distribution:
Origin: Sasa C
Label: some-label
Suite: suiteX
Codename: testing
Architectures: i386 amd64 all source
Components: main
Description: some desc
SignWith: 'NAME'

add/sign to the repo using: reprepro --ask-passphrase -A all -Vb . includedeb suiteX some-package.deb


B:
import public key: gpg --import export-file-of-public-key
import secret key: gpg --allow-secret-key-import --import export-file-of-secret-key

create ~/.rpmmacros and add this lines:
%_signature gpg
%_gpg_name NAME # same as one used to export public key on A

import public key to RPM DB: rpm --import export-file-of-public-key
sign the rpm package: rpm --addsign some-package.rpm

some useful commands:
list: rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n'
delete: rpm -e gpg-pubkey-22ed62d1-48460969
check: rpm --checksig some-package.rpm

C:
to be cont'd