Adding LICENSE file
[genesis.git] / fuel / build / install / uninstall.sh
1 #!/bin/bash -e
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12
13 my_exit() {
14     cd /tmp
15     if [ -d "$MOUNT" ]; then
16         fusermount -u $MOUNT
17         rmdir $MOUNT
18     fi
19 }
20 trap my_exit EXIT
21
22 echo "Live uninstall is currently disabled as it is not tested"
23 exit 1
24
25 TOP=`pwd`
26 MOUNT=`mktemp -d /tmp/XXXXXXX`
27 ssh-copy-id root@10.20.0.2
28 sshfs root@10.20.0.2:/ $MOUNT
29
30 DEST=$MOUNT
31 REPO=$DEST/var/www/nailgun/ubuntu/fuelweb/x86_64
32
33 cd $REPO
34 if [ ! -f  $REPO/dists/precise/main/binary-amd64/Packages.backup ]; then
35     echo "Error - didn't find backup file for Packages!"
36     exit 1
37 fi
38
39 if [ ! -f  $REPO/dists/precise/main/binary-amd64/Packages.gz.backup ]; then
40     echo "Error - didn't find backup file for Packages.gz!"
41     exit 1
42 fi
43
44 if [ ! -f  $REPO/dists/precise/Release.backup ]; then
45     echo "Error - didn't find backup file for Release!"
46     exit 1
47 fi
48
49 if [ ! -f $DEST/etc/puppet/manifests/site.pp.backup ]; then
50     echo "Error - didn't find backup file for site.pp!"
51     exit 1
52 fi
53
54 echo "Removing Debian packages:"
55 cd $TOP/release/pool/main
56 for deb in *.deb
57 do
58     echo "   $deb"
59     rm -Rf $REPO/pool/main/$deb
60 done
61 cd $REPO
62
63 echo "Removing Puppet modules:"
64 cd $TOP/puppet/modules
65 for dir in *
66 do
67     echo "   $dir"
68     rm -Rf $DEST/etc/puppet/modules/$dir
69 done
70 cd $REPO
71
72 echo "Restoring backups of datafiles"
73
74 rm -f $REPO/dists/precise/main/binary-amd64/Packages $REPO/dists/precise/main/binary-amd64/Packages.gz
75 rm -f $REPO/dists/precise/Release $DEST/etc/puppet/manifests/site.pp
76 mv $REPO/dists/precise/main/binary-amd64/Packages.backup $REPO/dists/precise/main/binary-amd64/Packages
77 mv $REPO/dists/precise/main/binary-amd64/Packages.gz.backup $REPO/dists/precise/main/binary-amd64/Packages.gz
78 mv $REPO/dists/precise/Release.backup $REPO/dists/precise/Release
79 mv $DEST/etc/puppet/manifests/site.pp.backup $DEST/etc/puppet/manifests/site.pp