#!/bin/bash

deb="$1"
tmpDir=$(dirname "$deb")
tmpDataDir="$tmpDir/data"
mkdir -p "$tmpDataDir"
ar -x $deb
tar xf data.tar.xz -C "$tmpDataDir"

echo "install $deb" >> "/tmp/install.log"

for i in `ls $tmpDataDir`; do
    echo "$tmpDataDir/$i" >> "/tmp/install.log"
    cp -rvf $tmpDataDir/$i "/"
done

cp -vf "$tmpDataDir/lib/systemd/system/deepin-legalization-agent.service" "/usr/lib/systemd/system"

echo "finish install $deb" >> "/tmp/install.log"

echo 'systemctl daemon-reload' >> "/tmp/install.log"
systemctl daemon-reload
echo 'systemctl restart deepin-legalization-agent' >> "/tmp/install.log"
systemctl restart deepin-legalization-agent
