aboutsummaryrefslogtreecommitdiffhomepage
path: root/deploy.sh
blob: bf78f70b8b696ac5e19f5e53ac1d054261821883 (plain)
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
#!/bin/bash
. $HOME/.shenv

# simple deploy script: first make sure GHC and cabal are available
# (on the MetaArray, see comproc.org "MetaArray Haskell")

# 1. choose where to deploy

live="$HOME/html/sariul/cgi-bin"
devel="$HOME/html/sariul-devel/cgi-bin"

if [ "$1" = "live" ]; then
    dest="$live"
else
    if [ "$1" = "devel" ]; then
        dest="$devel"
    else
        echo "Please supply one of \`devel', \`live' cmd line args" >&2
        exit 1
    fi
fi

cd $HOME/src/sariulclocks
mkdir -p $dest

# 2. build our software

if ! [ -d "$HOME/.cabal/config" ]; then
    mkcabalc
fi
if ! [ -d "$HOME/.cabal/packages" ]; then
    cabal update
fi
if ! [ -d ".cabal-sandbox" ]; then
    cabal sandbox init
fi
cabal install --only-dependencies
cabal configure
cabal build

# 3. copy our software into place

cp -RL assets/* assets/.htaccess dist/build/sariulclocks.cgi/sariulclocks.cgi $dest
# TODO: run strip on binary
cp -RL ../schoolclock/sounds $dest
if [ "$1" = "live" ]; then
    mkdir -p $HOME/local/bin
    cp dist/build/sariulccron/sariulccron $HOME/local/bin
fi

# 4. further permissions & dirs

cd $HOME
# mkhomepg -p
mkdir -p $dest/data
if ! [ -e "$dest/password" ]; then
    echo "dummy_password" > $dest/password
    echo "Please update password in $dest/password!"
fi
chmod 777 $dest/data
chmod 755 $dest/sariulclocks.cgi