2 PATH=/bin:/usr/bin:/sbin:/usr/sbin
4 # Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # @file 242.cert-svc-db-upgrade.sh.in
19 # @author Sangwan Kwon (sangwan.kwon@samsung.com)
20 # @brief cert-svc db migration scripts for platform upgrade 2.4 -> 3.0
23 OLD_DB=@CERT_SVC_OLD_DB_PATH@/certs-meta-old.db
24 NEW_DB=@CERT_SVC_DB_PATH@/certs-meta.db
26 MIGRATION_USER_TABLE=@CERT_SVC_DB_PATH@/migration-user-table.sql
29 mv @CERT_SVC_OLD_DB_PATH@/certs-meta.db $OLD_DB
30 rm -rf @CERT_SVC_OLD_DB_PATH@/certs-meta.db-journal
32 # remove deprecated dir
33 rm -rf @CERT_SVC_PKCS12@/storage
35 # install new database
36 cp @UPGRADE_DATA_PATH@/certs-meta.db $NEW_DB
38 # migration user certs db
39 touch $MIGRATION_USER_TABLE
40 echo "ATTACH DATABASE '$OLD_DB' as 'tmp';" >> $MIGRATION_USER_TABLE
41 echo "INSERT INTO wifi SELECT * FROM tmp.wifi;" >> $MIGRATION_USER_TABLE
42 echo "INSERT INTO vpn SELECT * FROM tmp.vpn;" >> $MIGRATION_USER_TABLE
43 echo "INSERT INTO email SELECT * FROM tmp.email;" >> $MIGRATION_USER_TABLE
44 echo "DETACH DATABASE 'tmp';" >> $MIGRATION_USER_TABLE
45 sqlite3 $NEW_DB ".read $MIGRATION_USER_TABLE"
46 rm -rf $MIGRATION_USER_TABLE
48 # update schema version to 2.4 (this is for bundle upgrade)
49 sqlite3 $NEW_DB "UPDATE schema_info SET version='1', description='Tizen 2.4' \
52 # update disabled certs on db
53 disabled_certs_cnt=`sqlite3 $OLD_DB "SELECT count(*) FROM disabled_certs;"`
54 if [ "$disabled_certs_cnt" != "0" ]
56 @UPGRADE_SCRIPT_PATH@/243.cert-svc-disabled-certs-upgrade.sh $OLD_DB $NEW_DB
61 # generate blank journal file newly
64 # support backward compatablity
65 ln -sf @TZ_SYS_CA_BUNDLE@ @CERT_SVC_CA_BUNDLE@
66 chown -h @USER_NAME@:@GROUP_NAME@ @CERT_SVC_CA_BUNDLE@
69 chsmack -a @SMACK_DOMAIN_NAME@ @CERT_SVC_DB_PATH@/*
70 chown @USER_NAME@:@GROUP_NAME@ @CERT_SVC_DB_PATH@/*
71 chmod 644 @CERT_SVC_DB_PATH@/*