-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·55 lines (47 loc) · 1.94 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# WARNING:
# This script is a helper that the developers use to call Cnchi (testing purposes only)
# Please, do not use if your intention is to do a "normal" installation
CNCHI_DIR=`pwd`
_DEFAULT_DIR=/usr/share/cnchi
_PYTHON="/usr/bin/python"
_PYTHON_OPTIONS="-Wall"
_XML="/usr/share/cnchi/data/packages.xml"
_CNCHI_OPTIONS="-d -v --disable-rank-mirrors" #-s bugsnag"
_POLICY_FILE='com.antergos.pkexec.cnchi.policy'
_CNCHI_BIN="/usr/share/cnchi/dist/bin/cnchi"
[[ -d /home/dustin ]] && _CNCHI_OPTIONS="${_CNCHI_OPTIONS} -z"
# If we aren't running on Arch make sure we use python3
[[ -f /etc/arch-release ]] || _PYTHON="/usr/bin/python3"
# Removes symlink and moves cnchi that was installed
# via pacman back to /usr/share/cnchi
cleanup() {
if [[ -h "${_DEFAULT_DIR}" && -e "${_DEFAULT_DIR}.tmp" ]]; then
sudo unlink "${_DEFAULT_DIR}"
sudo mv "${_DEFAULT_DIR}.tmp" "${_DEFAULT_DIR}" > /dev/null 2>&1
fi
_pid=$(cat /tmp/cnchi.pid)
echo ${_pid}
sudo kill ${_pid}
}
# Make sure we cleanup upon exiting.
trap cleanup EXIT QUIT TERM
# If /usr/share/cnchi exists, is not a symlink, and is not the current directory then it was installed
# with pacman (so its not our development copy). Move it out of the way temporarily.
# Symlink our development copy to /usr/share/cnchi only if we weren't called from that directory
if [[ -h "${_DEFAULT_DIR}" ]]; then
DONT_SYMLINK=true
elif [[ -d "${_DEFAULT_DIR}" && "${CNCHI_DIR}" != "${_DEFAULT_DIR}" ]]; then
sudo mv "${_DEFAULT_DIR}" "${_DEFAULT_DIR}.tmp" > /dev/null 2>&1
sudo ln -sf "${CNCHI_DIR}" "${_DEFAULT_DIR}"
fi
# If our polkit policy file is not installed, install it and then restart polkit
[[ -f "/usr/share/polkit-1/actions/${_POLICY_FILE}" ]] || {
sudo cp "dist/polkit-1/actions/${_POLICY_FILE}" /usr/share/polkit-1/actions && sudo systemctl restart polkit
}
if [[ -z "$1" ]]; then
pkexec $_CNCHI_BIN $_CNCHI_OPTIONS -p $_XML ${@} 2>&1
else
# Running through PyCharm Debugger
pkexec $_PYTHON ${@} #2>&1
fi