File deepin-daemon-polkit-installer.in of Package deepin-daemon

#!/bin/bash
# Name: Deepin polkit profiles installer
# Version: 1.1
# Description: On openSUSE, deepin-daemon does not install polkit profiles by default
# for security. The tool can help users to install these profiles for getting the
# full features of Deepin Desktop, if user does not care security.
# Author: Hillwood Yang <hillwood@opensuse.org>
# License: WTFPL-2.0

if [ "$(id -u)" != "0" ]; then
	echo "error: You must be root to use this program!"
	exit 1
fi

while :
do
    ANSWER=n
    echo "This is the Deepin daemon polkit installer, it helps you to install the polkit \
profiles for Deepin daemon. These profiles will enable the full features for Deepin Desktop."
    echo "These polkit profiles are not appraised by SUSE security Team. Maybe install these \
profiles bring some unknown security issues. Are you sure that you install \
this files anyhow?[Yes/No]N"
    read ANSWER
    case $ANSWER in
        Y | y | yes | Yes)
            break;;
        N | n | no | No)
            break;;
        *)
            echo "Unknown response, please reinput";;
    esac
done

if [ "$ANSWER" = "n" ] || [ "$ANSWER" = "N" ] || [ "$ANSWER" = "no" ] || [ "$ANSWER" = "No" ]; then
    echo "Exit deepin-daemon-dbus installation."
    exit 1
fi

SYSTEM_TMP=/root/.cache
TMP_DIR=$SYSTEM_TMP/deepin-daemon-polkit

pushd /usr/share/polkit-1/actions/ &>/dev/null

    Filelist=&(ls com.deepin.daemon*) &>/dev/null

    if [ "$Filelist" != "" ]; then
        rm -rf "$Filelist"
    fi

popd &>/dev/null

mkdir -p $TMP_DIR

pushd $TMP_DIR &>/dev/null
    tar -xvf /usr/share/dde-daemon/polkit.tar.gz &>/dev/null
    cp polkit/* /usr/share/polkit-1/actions/
    chmod 0644 /usr/share/polkit-1/actions/com.deepin.daemon*
popd &>/dev/null

rm -rf $TMP_DIR

echo "Deepin polkit profiles install succeed!"
openSUSE Build Service is sponsored by