--- /dev/null
+#!/bin/sh
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+if [ ! -f /opt/usr/dbspace/.stc-manager-datausage.db ]
+then
+ /usr/bin/sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db 'PRAGMA journal_mode = PERSIST;
+ PRAGMA user_version = 1;
+ CREATE TABLE IF NOT EXISTS statistics (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ binpath TEXT NOT NULL,
+ received BIGINT,
+ sent BIGINT,
+ time_stamp BIGINT,
+ iftype INT,
+ is_roaming INT,
+ hw_net_protocol_type INT,
+ ifname TEXT,
+ subscriber_id TEXT,
+ ground INT
+ );
+ CREATE TABLE IF NOT EXISTS restrictions (
+ restriction_id INTEGER PRIMARY KEY AUTOINCREMENT,
+ binpath TEXT,
+ iftype INT,
+ ifname TEXT,
+ rstn_type INT,
+ roaming INT,
+ subscriber_id TEXT NOT NULL,
+ data_limit BIGINT,
+ data_warn_limit BIGINT,
+ monthly_limit BIGINT,
+ weekly_limit BIGINT,
+ daily_limit BIGINT,
+ month_start_date INT
+ );
+ CREATE INDEX IF NOT EXISTS restrictions_index ON restrictions (binpath, iftype, ifname);
+ CREATE TABLE IF NOT EXISTS counters (
+ restriction_id INTEGER NOT NULL,
+ data_counter BIGINT,
+ warn_counter BIGINT,
+ monthly_counter BIGINT,
+ weekly_counter BIGINT,
+ daily_counter BIGINT,
+ month_start_date INT,
+ month_start_ts BIGINT,
+ week_start_ts BIGINT,
+ day_start_ts BIGINT,
+ PRIMARY KEY (restriction_id)
+ );
+ CREATE TABLE IF NOT EXISTS fw_lock (
+ name TEXT PRIMARY KEY,
+ state INT
+ );
+ CREATE TABLE IF NOT EXISTS fw_chains (
+ chain TEXT PRIMARY KEY,
+ target INT,
+ priority INT
+ );
+ CREATE TABLE IF NOT EXISTS fw_rules (
+ key BIGINT PRIMARY KEY,
+ chain TEXT NOT NULL,
+ direction INT,
+ s_ip_type INT,
+ d_ip_type INT,
+ s_port_type INT,
+ d_port_type INT,
+ protocol INT,
+ family INT,
+ s_ip1 TEXT NOT NULL,
+ s_ip2 TEXT NOT NULL,
+ d_ip1 TEXT NOT NULL,
+ d_ip2 TEXT NOT NULL,
+ s_port1 INT,
+ s_port2 INT,
+ d_port1 INT,
+ d_port2 INT,
+ ifname TEXT NOT NULL,
+ target INT,
+ log_level INT,
+ log_prefix TEXT NOT NULL,
+ nflog_group INT,
+ nflog_prefix TEXT NOT NULL,
+ nflog_range INT,
+ nflog_threshold INT,
+ identifier TEXT NOT NULL
+ );
+ CREATE INDEX IF NOT EXISTS rules_index ON fw_rules (chain, target);'
+fi
+
+/usr/bin/chmod 660 /opt/usr/dbspace/.stc-manager-datausage.db
+/usr/bin/chmod 660 /opt/usr/dbspace/.stc-manager-datausage.db-journal
+
+/usr/bin/chsmack -a _ /opt/usr/dbspace/.stc-manager-datausage.db
+/usr/bin/chsmack -a _ /opt/usr/dbspace/.stc-manager-datausage.db-journal
%define enable_statistics YES
%define enable_restriction YES
%define database_full_path /opt/usr/dbspace/.stc-manager-datausage.db
+%define upgrade_script_path /usr/share/upgrade/scripts
+%define upgrade_data_path /usr/share/upgrade/data
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf
+#Upgrade script file
+mkdir -p %{buildroot}%{upgrade_script_path}
+mkdir -p %{buildroot}%{upgrade_data_path}
+cp -f scripts/500.stc-manager-upgrade.sh %{buildroot}%{upgrade_script_path}
+cp -f data/init_stc_db.sh %{buildroot}%{upgrade_data_path}
+
%post plugin-net-popup
rm %{_libdir}/stc-plugin-popup.so
ln -s %{_libdir}/stc-plugin-net-popup.so %{_libdir}/stc-plugin-popup.so
%if %{?enable_database} == YES
%config(noreplace) %attr(660, root, root) %{database_full_path}
%config(noreplace) %attr(660, root, root) %{database_full_path}-journal
+%{upgrade_script_path}/500.stc-manager-upgrade.sh
+%{upgrade_data_path}/init_stc_db.sh
%endif
%files plugin-appstatus
--- /dev/null
+#!/bin/sh
+
+#---------------------------------------------------------#
+# stc-manager patch for upgrade (3.0 -> the latest tizen) #
+#---------------------------------------------------------#
+
+# Macro
+UPGRADE_DATA_PATH=/usr/share/upgrade/data/
+NETWORK_DATA_PATH=/opt/usr/data/network/
+DBSPACE_PATH=/opt/usr/dbspace
+
+# Copy the script for creating db
+mkdir -p $NETWORK_DATA_PATH
+cp $UPGRADE_DATA_PATH/init_stc_db.sh $NETWORK_DATA_PATH
+chmod 755 $NETWORK_DATA_PATH/init_stc_db.sh
+
+# Make db
+$NETWORK_DATA_PATH/init_stc_db.sh