3 if [ "$MOUNTPOINT" == "" ]; then
4 echo "Usage: $0 <mountpoint>"
7 if [ -e ${MOUNTPOINT}/openxpki_live.ext2
]; then
8 echo "openxpki_live.ext2 already exists, will not overwrite it. If you really want to deploy freshly, delete ${MOUNTPOINT}/openxpki_live.ext2"
11 echo "Redeploying OpenXPKI, this will take a while"
12 # clear the current databases and remove config
13 openxpkiadm initdb
--force
14 rm /var
/openxpki
/sqlite.db
*
15 rm -r /etc
/openxpki
/instances
/trustcenter
1/*
16 # stop networking, the user should be on the console anyways ...
17 /etc
/init.d
/networking stop
19 dpkg-reconfigure openxpki-deployment
20 # we are left with SQLite again, redeploy with MySQL
21 rm /etc
/openxpki
/instances
/trustcenter
1/database.xml
22 rm /etc
/openxpki
/instances
/trustcenter
1/log_database.xml
23 openxpki-configure
--batch -- -setcfg database.
type=MySQL
--setcfg database.name
=openxpki
--setcfg database.
host=localhost
--setcfg database.port
=3306 --setcfg database.user
=openxpki
--setcfg database.passwd
=pki
24 # migrate password and aliases from sqlite database to MySQL
25 (echo '.mode insert'; echo 'select * from certificate;')|sqlite3
/var
/openxpki
/sqlite.db._backend_|
sed -e 's/INSERT INTO table/INSERT INTO certificate/'|mysql
-uopenxpki -ppki openxpki
26 (echo '.mode insert'; echo 'select * from aliases;')|sqlite3
/var
/openxpki
/sqlite.db._backend_|
sed -e 's/INSERT INTO table/INSERT INTO aliases/'|mysql
-uopenxpki -ppki openxpki
27 /etc
/init.d
/openxpkid stop
28 /etc
/init.d
/apache stop
29 /etc
/init.d
/mysql stop
31 dd if=/dev
/zero of
=${MOUNTPOINT}/openxpki_live.ext2 count
=200000 ||
(echo "Problem creating 100 MB image - no space left on device?"; exit 1)
32 mkfs.ext2
-F ${MOUNTPOINT}/openxpki_live.ext2
33 losetup
/dev
/loop0
${MOUNTPOINT}/openxpki_live.ext2
35 mount
/dev
/loop0
/mnt
/loop
36 # copy config and MySQL database to image, create symbolic links
37 mkdir
-p /mnt
/loop
/openxpki_live
/etc
/mysql
38 mkdir
-p /mnt
/loop
/openxpki_live
/etc
/openxpki
39 mkdir
-p /mnt
/loop
/openxpki_live
/var
/lib
/mysql
40 cp -ar /etc
/openxpki
/* /mnt
/loop
/openxpki_live
/etc
/openxpki
41 cp -ar /var
/lib
/mysql
/* /mnt
/loop
/openxpki_live
/var
/lib
/mysql
42 cp -ar /etc
/mysql
/* /mnt
/loop
/openxpki_live
/etc
/mysql
44 ln -s /mnt
/loop
/openxpki_live
/etc
/mysql
/etc
/mysql
46 ln -s /mnt
/loop
/openxpki_live
/var
/lib
/mysql
/var
/lib
/mysql
48 ln -s /mnt
/loop
/openxpki_live
/etc
/openxpki
/etc
/openxpki
49 /etc
/init.d
/mysql start
50 /etc
/init.d
/openxpkid start
51 /etc
/init.d
/apache start
52 echo "Successfully redeployed to ${MOUNTPOINT}, you should now be able to use a persistent OpenXPKI"