Merge remote branch 'origin/demonstration'
[deska.git] / scripts / deska-demo.sh
blobed73148860029e0d75536066f5b623f7cffba839
1 #!/bin/bash
3 function die() {
4 echo $1
5 exit 1
8 /bin/ls -al deska-*.rpm > /dev/null 2> /dev/null \
9 || die "Please run the deska-demo.sh from a directory which contains the RPM packages."
11 echo "Installing packages..."
13 # Install the packages
14 yum -y localinstall *.rpm || die "Error when installing packages"
16 yum install -y yum-conf-epel
17 yum install -y GitPython
19 echo "Starting PostgreSQL..."
20 service postgresql-9.0 initdb || die "Cannot initialize the PostgreSQL server"
21 service postgresql-9.0 start || die "Cannot start PostgreSQL server"
23 echo "Creating user franta..."
24 useradd franta || die "Cannot add user franta"
25 echo -e "franta\nfranta\n" | passwd franta --stdin || die "Cannot change franta's password"
26 echo -e "[DBConnection]\nServer=/usr/local/bin/deska-server-wrapper\n" > ~franta/deska.ini
27 echo -e "LESS=-r\nexport LESS\n" >> ~franta/.bash_profile
29 echo "Creating the PostgreSQL database"
31 su postgres -c 'psql -q -U postgres -c "DROP DATABASE IF EXISTS d_fzu;"' || die "Drop database"
32 su postgres -c 'psql -q -U postgres -c "CREATE ROLE deska_admin;"' || die "Create role deska_admin"
33 su postgres -c 'psql -q -U postgres -c "CREATE ROLE deska_user;"' || die "Create role deska_user"
34 su postgres -c 'psql -q -U postgres -c "CREATE USER franta;"' || die "Create user franta"
35 su postgres -c 'psql -q -U postgres -c "GRANT deska_admin TO franta;"' || die "Cannot grant deska_admin"
36 su postgres -c 'psql -q -U postgres -c "GRANT deska_user TO franta;"' || die "Cannot grant deska_user"
37 su postgres -c 'psql -q -U postgres -c "CREATE DATABASE d_fzu OWNER deska_admin;"' || die "Create database"
39 su postgres -c 'psql -q -U postgres -d d_fzu -v ON_ERROR_STOP=1 -f /usr/share/deska/install-scripts/install/pgpython.sql' || die "Installing pgpython"
41 echo "Deploying Deska into the database"
42 cd /usr/share/deska/install-scripts/install
44 mkdir -p /var/lib/deska
45 chown postgres:postgres /var/lib/deska
47 su postgres -c "DESKA_SCHEME=fzu ./deska-deploy-database.sh -U postgres -d d_fzu -t /var/lib/deska/d_fzu" \
48 || die "Cannot deploy the database scheme"
50 echo "Initializing Git stuff..."
51 mkdir /var/lib/deska/cfggen
52 cd /usr/share/deska/install-scripts
53 ./tests/prepare-git-repo.sh /var/lib/deska/cfggen
55 export DESKA_CFGGEN_BACKEND=git
56 echo -e "#!/bin/bash
57 export DESKA_DB=d_fzu
58 export DESKA_CFGGEN_BACKEND=git
59 export DESKA_CFGGEN_SCRIPTS=/var/lib/deska/cfggen/scripts
60 export DESKA_CFGGEN_GIT_REPO=/var/lib/deska/cfggen/cfggen-repo
61 export DESKA_CFGGEN_GIT_WC=/var/lib/deska/cfggen/cfggen-wc
62 export DESKA_CFGGEN_GIT_PRIMARY_CLONE=/var/lib/deska/cfggen/cfggen-primary
63 export DESKA_CFGGEN_GIT_SECOND=/var/lib/deska/cfggen/second-wd
64 /usr/bin/deska-server
65 " > /usr/local/bin/deska-server-wrapper
66 chmod +x /usr/local/bin/deska-server-wrapper
68 echo "All done. Please login as user 'franta' (pw 'franta') and run 'deska-cli' to evaluate the Deska system."