Marius van Witzenburg "Learned my lesson in life, now setting my action to stay in life."

22Jun/100

Seven reasons why ERP (Enterprise Resource Planning) projects fail

1. Poor or undefined project objectives, roles and responsibilities, leading to unrealistic expectations being set.
2. Lack of communication between IT and the business, resulting in a mismatch of requirements and expectations.
3. No senior business sponsor and separate project manager.
4. Technology put before people: no or minimal involvement of key users during the “scoping” phase and lack of regular communication with them throughout the project implementation
5. No project success metrics.
6. No risk assessment or contingency plan.
7. Lack of regular checks to ensure the project is on track to time and budget.

24Mar/100

Test-driven development (TDD)

When I was googling for development flows I found the following page which almost describes completely how I work in my development projects.

A flowchart of how this goes:

Test driven development 512x367 Test driven development (TDD)

For more info see: http://en.wikipedia.org/wiki/Test-driven_development

23Mar/100

Yet another sync script for two Western Digital ShareSpace drives via rsync

This script simply syncs from a WD ShareSpace drive to another WD ShareSpace drive.

On a FreeBSD (in my case) machine create the following files:

/backup/sharespace/ssh-wrapper

1
2
#!/bin/sh
sh /backup/run &

/backup/sharespace/run

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/sh
# WD ShareSpace sync script v1.1
# By Marius van Witzenburg <info@mariusvw.com>
# http://mariusvw.com
#
# Works with busybox 1.1.1 and newer versions.
#
 
# Settings
source="192.168.8.4"
target="192.168.8.9"
mailto="info@mariusvw.com"
mailfrom="noreply@mariusvw.com"
daemon="yes"
force="no"
waittime=5
maxlogs=48
beforetime=6
aftertime=20
 
#
# DO NOT CHANGE BELOW!
#
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
PID=$$
rarg="-aWvz"
 
curdir=`pwd`
cd /backup/
 
echo ${PID} > /backup/run.pid
cleanup() {
    rm /backup/key
    cd ${curdir}
    ssh -ax root@${target} "test -f /backup/rsyncd.pid && kill \`cat /backup/rsyncd.pid\`"
    return $?
}
s_hup() {
    logger -s -p daemon.notice -t 'backup' "*** SIGHUP! Ignoring... ***"
    #exit $?
}
s_int() {
    logger -s -p daemon.notice -t 'backup' "*** SIGINT! Exiting... ***"
    cleanup 
    echo -e "From: ${mailfrom}\nTo: ${mailto}\nSubject: ShareSpace backup.\n\nSIGINT! Exiting..." | /usr/sbin/msmtp ${mailto}
    rm /backup/run.pid
    kill ${JOB}
    exit $? 
}
s_term() {
    logger -s -p daemon.notice -t 'backup' "*** SIGTERM! Exiting... ***"
    cleanup
    echo -e "From: ${mailfrom}\nTo: ${mailto}\nSubject: ShareSpace backup.\n\nSIGTERM! Exiting..." | /usr/sbin/msmtp ${mailto}
    rm /backup/run.pid
    kill ${JOB}
    exit $?
}
 
trap s_hup SIGHUP
trap s_int SIGINT
trap s_term SIGTERM
 
if [ "${daemon}" = "yes" ]
then
    logger -s -p daemon.notice -t 'backup' "Having a rest for the first run..."
    sleep 30 &
    JOB=$!
    wait ${JOB}
fi
 
while [ "true" ]
do
    # Time to backup?
    hour=`date "+%H"`
    if [ "${hour}" -lt "${beforetime}" ] || [ "$hour" -gt "${aftertime}" ]
    then
        # Change the \1 to 1-3 depending on which load you want
        loadavg=`uptime | sed 's/.*average: \([0-9]\).*/\1/g'`
        if [ "${loadavg}" -eq 0 ] || [ "${force}" = "yes" ]
        then
            alive=`ssh -ax -q -q -o "BatchMode=yes" -o "ConnectTimeout 5" root@${target} "echo 2>&1" && return 0 || echo 1`
            if [ "${alive}" -eq 0 ]
            then
                user=`echo $(head /dev/urandom)$(date +%Y%m%d%H%M%S%N) | md5sum | uuencode -m -| sed -n 2p | cut -c3-43 | cut -c1-${1:-16}`
                sleep 1
                pass=`echo $(head /dev/urandom)$(date +%Y%m%d%H%M%S%N) | md5sum | uuencode -m -| sed -n 2p | cut -c3-43 | cut -c1-${1:-16}`
                echo ${pass} > /backup/key
 
                test -d /backup/log || mkdir /backup/log
                test -d /backup/server || mkdir /backup/server
 
                test -f /backup/log/run.${maxlogs} && rm -f /backup/log/run.${maxlogs}
                lcur=${maxlogs}
                while [ ${lcur} -gt 1 ]
                do
                    lpre=${lcur}
                    lcur=`expr ${lcur} - 1`
                    test -f /backup/log/run.${lcur}.gz && mv /backup/log/run.${lcur}.gz /backup/log/run.${lpre}.gz
                done
                test -f /backup/log/run && mv /backup/log/run /backup/log/run.1
                test -f /backup/log/run.1 && gzip /backup/log/run.1
 
                touch /backup/log/run
 
                logger -s -p daemon.notice -t 'backup' "Creating rsync server configuration"
 
                cat > /backup/server/rsyncd.conf < <EOF
pid file = /backup/rsyncd.pid
 
[shares]
path = /shares/
comment = Rsync Server
uid = root
gid = jewab
use chroot = no
read only = no
list = no
auth users = ${user}
secrets file = /backup/rsync.users
EOF
 
                cat > /backup/server/rsync.users < <EOF
${user}:${pass}
EOF
 
                cat > /backup/server/start < <EOF
#!/bin/sh
rsync --daemon --config=/backup/rsyncd.conf &
EOF
 
                # Transfer server files
                rsync -e 'ssh -ax' ${rarg} --timeout=30 --delete /backup/server/ ${target}:/backup/ >> /backup/log/run 2>&1 &
                JOB=$!
                wait ${JOB}
 
                # Start rsync server
                ssh -ax root@${target} "sh /backup/start > /dev/null 2>&1; exit"
                JOB=$!
                wait ${JOB}
 
                # Sync internal shares and exclude usb shares
                logger -s -p daemon.notice -t 'backup' "Syncing internal shares..."
                rsync ${rarg} --timeout=60 --password-file=/backup/key --exclude="/usb[1-3]-1share1" --delete /shares/ rsync://${user}@${target}/shares/ >> /backup/log/run 2>&1 &
                JOB=$!
                wait ${JOB}
                tail -2 /backup/log/run | logger -s -p daemon.info -t 'backup'
 
                # Sync usb shares if connected
                for x in `ssh -ax root@${target} ls -l /shares/| grep "^d" | awk '{ print $9 }'`
                do
                    if [ ! -z "`expr ${x} : '\(usb[0-9]-[0-9]share[0-9]\)'`" ]
                    then
                        if [ -d "/shares/${x}/" ]
                            then
                            logger -s -p daemon.notice -t 'backup' "Syncing ${x}..."
                            rsync ${rarg} --timeout=60 --password-file=/backup/key --delete /shares/${x}/ rsync://${user}@${target}/shares/${x}/ >> /backup/log/run 2>&1 &
                            JOB=$!
                            wait ${JOB}
                            tail -2 /backup/log/run | logger -s -p daemon.info -t 'backup'
                        fi
                    fi
                done
 
                sleep 5
 
                echo -e "From: ${mailfrom}\nTo: ${mailto}\nSubject: ShareSpace backup.\n\nCycle finished..." | /usr/sbin/msmtp ${mailto}
 
                # Shutdown rsync server
                cleanup
            else
                logger -s -p daemon.notice -t 'backup' "No access to '${target}' - aborting"
            fi
        else
            logger -s -p daemon.notice -t 'backup' "Load average on '${source}' is ${loadavg} - aborting"
        fi
    else
        logger -s -p daemon.notice -t 'backup' "Not the time to make backups - sleeping"
    fi
 
    # Daemonize or stop?
    if [ "${daemon}" != "yes" ]
    then
        logger -s -p daemon.notice -t 'backup' "Backup finished"
        break
    fi
 
    # Cycle
    logger -s -p daemon.notice -t 'backup' "Waiting for cycle (${waittime} minutes)..."
    sleep `expr ${waittime} \* 60` &
    JOB=$!
    wait ${JOB}
    logger -s -p daemon.notice -t 'backup' "Running cycle..."
done
 
# EOF

/backup/sync.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/local/bin/bash
#
# Sync backup system on ShareSpace drive
#
 
ip="192.168.8.4"
 
# Fix permissions
find /backup/sharespace/ -type d -exec chmod 700 '{}' \; 
find /backup/sharespace/ -type f -exec chmod 600 '{}' \; 
 
echo "-- Shutting down current backup"
ssh -ax root@${ip} "test -f /backup/run.pid && kill \`cat /backup/run.pid\`"
sleep 15
echo "-- Syncing new files"
rsync -e 'ssh -ax' -aWv --timeout=30 --exclude '.svn' --delete --delete-excluded /backup/sharespace/ root@${ip}:/backup/
echo "-- Restarting backup"
ssh -ax root@${ip} "sh /backup/ssh-wrapper > /dev/null 2>&1; exit"
 
# EOF

After creating these files set these permissions and start the script:

chmod 700 /backup/sync.sh
/backup/sync.sh

Keep in mind that you setup SSH-keys before you use these scripts :-)

Have fun!

22Mar/102

How to fix USB sticks that may damage or destroy your computer

In this 'tutorial' I'll show you how to fix a unsafe USB stick that can really damage your computer.

The problem with these USB sticks is the iron plate on the back, when you put it into the USB port the other way around you create a short circuit on the motherboard. New computers detect this and give an alert or instant power off.
Old computers simply start to have a little barbecue fire inside... Which might not be what to expect from a USB stick.

First we have the normal USB stick, nothing special...
 How to fix USB sticks that may damage or destroy your computer

Lets bend the iron plate a bit for so we can grab it...
 How to fix USB sticks that may damage or destroy your computer

This will result in the following.
 How to fix USB sticks that may damage or destroy your computer

Then bend the plate over the whole width of the USB stick like this.
 How to fix USB sticks that may damage or destroy your computer

The USB flash chip is now lose from the slide tray.
 How to fix USB sticks that may damage or destroy your computer

Pull out the USB flash chip.
 How to fix USB sticks that may damage or destroy your computer

Next, pull out the iron plate!
 How to fix USB sticks that may damage or destroy your computer

Tataah, no plate... Empty stick...
 How to fix USB sticks that may damage or destroy your computer

Another view of it.
 How to fix USB sticks that may damage or destroy your computer

You should have these parts now, if not, something went wrong.
 How to fix USB sticks that may damage or destroy your computer

The next thing we do is... Glue it!
 How to fix USB sticks that may damage or destroy your computer

Put some glue on the slider tray.
 How to fix USB sticks that may damage or destroy your computer

Place the flash chip back on the slider tray.
 How to fix USB sticks that may damage or destroy your computer

Which should result like this, and your done.
 How to fix USB sticks that may damage or destroy your computer

Now you know how to take apart this.
 How to fix USB sticks that may damage or destroy your computer

Resulting into this.
 How to fix USB sticks that may damage or destroy your computer

And this...
 How to fix USB sticks that may damage or destroy your computer

And then put it back together until you get this.
 How to fix USB sticks that may damage or destroy your computer

This project was sponsored by PersC.

19Mar/100

A fire on the other side of the street at my work in Rotterdam

We actually first didn't noticed this fire...

Until we heard some sirens going by...

The fire is gone now and nobody got really hurt. The crane machinist got light poisoned by the smoke, but he'll survive.

The building damage looks a bit worse, no clue how bad it is.

Some pictures:

2Mar/100

Shellproxy, an easy tool to run shell commands from PHP or other languages

This is a simple script that runs a shell command from PHP with the function system().
It sometimes happens that a command doesn't close the stdin or stdout, resulting the system() function to halt and wait for it to finish...
This causes PHP to reach the 30 second time limit and kill the script.

This script runs it in the background and you could make your commands send their output to a log file and still having full control.

Read the code below how to use it.

You can compile it by placing the code into 'shellproxy.c' and then compile it with the following command:

gcc -o shellproxy shellproxy.c

I hope this is something useful for you as it was for me.

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
32
33
34
35
#include <stdio .h>
#include <stdlib .h>
#include <string .h>
 
int main(int argc, char *argv[]) {
    char command[1024];
    int t;
 
    if (argc == 1) {
        printf("\nShell Proxy\n");
        printf("By Marius van Witzenburg <http ://mariusvw.com>\n\n");
        printf("You will mostly use this program from PHP or any other\n");
        printf("webscripting language to background run programs\n\n");
        printf("Usage:\n");
        printf("- CLI:\n");
        printf("shellproxy \"<cmd> <arg>\"\n");
        printf("shellproxy \"<cmd> <arg> > redirect.txt\"\n");
        printf("- PHP:\n");
        printf("system('shellproxy \"<cmd> <arg> &\"');\n");
        printf("system('shellproxy \"<cmd> <arg> > redirect.txt\"');\n\n");
    }
 
    command[0] = 0;
 
    for (t = 1; t < argc; t++) {
        strcat(command, argv[t]);
        strcat(command, " ");
    }
 
    fclose(stdin);
    fclose(stdout);
    fclose(stderr);
 
    system(command);
}

It would be nice if you keep my name mentioned into this code if you use it.

Ps. Donations are welcome... ;-)

1Mar/101

project: www.slagboomvld.nl

We finished the website of Slagboom Vlaardingen.

Its viewable at http://www.slagboomvld.nl

In the gallery below the left one is the old design and the right side is the new design.

Design & Development by PersC

17Sep/090

The great hosting provider supporting my site with their good service.

My site is quite fast as you might notice and I find it very easy to manage all the things I need to manage.

For those things I can't manage or don't want to manage I have the provider Spothost.

They provide a great service and stability for a price that I can pay, I don't have to worry about tons of setting to choose from to keep my site running, even for mail its a few clicks and you're done. And if you have any question you can always contact them via the contact details on the Spothost website.

If you need custom hosting and a good service, a default hosting package, a dedicated server or a VPS solution. I'd advice you to contact them!

Spothost, my provider who gives me all I want on the internet :-)

18Aug/090

Test a mailserver its load with a mailbom, how easy.

Mostly when you setup a mailserver you also want a spam filter and a lot performance for delivering your mail local and remote.

For this you can easily use deffybomb.

This is a simple script that spams your target address with a shit load of mails depending of what you define.

Deffybomb is made by DrPhil. The author info is in the script in case you want to contact DrPhill :)

This script is not for abuse usage, its just for testing purposes!

Have fun testing! ;)

6Aug/093

A keyboard, but what is wrong with it?

Can you figure it out? :)

IMG 0411 512x383 A keyboard, but what is wrong with it?

Tagged as: , 3 Comments
Page 1 of 41234