-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathINSTALL.sh
More file actions
executable file
·143 lines (138 loc) · 6.39 KB
/
Copy pathINSTALL.sh
File metadata and controls
executable file
·143 lines (138 loc) · 6.39 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#! /bin/bash
# set -e # devel
# DEFINE FIRST THE CURRENT USER NAME
C_USER=$(stat -c %U -- /run/user/*| grep -v "root")
# CHECK IF USER IS IN SU MODE
S_USER=$(whoami)
PREFIX=/usr/local
USER_DIR=/home/${C_USER}
CONF_DIR=${USER_DIR}/.zenvidia
INSTALL_DIR=${PREFIX}/share/zenvidia
BIN_DIR=${PREFIX}/bin
locale=$(awk -F"." '{print $1}' <<< $LANG)
## terminal fonts colors.
red='\e[1;31m'
yel='\e[0;33m'
grn='\e[0;32m'
blu='\e[0;34m'
cya='\e[0;36m'
pur='\e[0;35m'
nc='\e[0m'
check_su(){
if [ ${S_USER} != "root" ]; then
echo -e "${red}WARNING: You can't run this shell as ${S_USER}. You must be ROOT${nc}"; exit ; fi
}
make_install(){
## pre install
mkdir -p ${INSTALL_DIR} ${CONF_DIR}/{compats/series,updates,release} # TODO remove compat updates
mkdir -p ${PREFIX}/share/{applications,pixmaps,doc/zenvidia}
mkdir -p ${INSTALL_DIR}/{temp,build,log,release,backups,compats,locale/locale_dev/locale_po} # TODO remove temp,build; release compat
## install system
install -Dm755 -t ${BIN_DIR}/ zenvidia zen_notify zen_start zen_task_menu zenvidia-modules-reload
install -Dm644 -t ${INSTALL_DIR}/ *.conf
install -Dm644 -t ${INSTALL_DIR}/ README.md
install -Dm644 -t ${INSTALL_DIR}/ OLD-README.md
install -Dm644 -t ${PREFIX}/share/applications/ desktop_files/{zenvidia,zenvidia-unpriviledge}.desktop
install -Dm644 -t ${PREFIX}/share/pixmaps/ pixmaps/*.png
install -Dm644 -t ${PREFIX}/share/doc/zenvidia/ docs/*.txt
install -Dm644 -t ${PREFIX}/share/doc/zenvidia/ docs/*.xml
install -Dm644 -t ${PREFIX}/share/doc/zenvidia/ Changelog.txt
install -Dm644 -t /usr/share/polkit-1/actions/ com.github.pkexec.zenvidia.policy
install -Dm644 -t /usr/share/polkit-1/rules.d/ com.github.zenvidia.rules
install -Dm644 -t ${INSTALL_DIR}/locale_dev locale/{Readme_translation.txt,translation_report_helper.sh,translation.pot}
install -Dm644 -t ${INSTALL_DIR}/locale_dev/locale_po locale/locale_dev/*
cp -rf -t ${INSTALL_DIR}/ locale/locale
# install user
mkdir -p ${USER_DIR}/.config/autostart ${CONF_DIR}/{compats/series,updates,release,backups}
install -Dm644 -t ${CONF_DIR}/ basic.conf distro.conf
# install -Dm644 -o ${C_USER} -g ${C_USER} -t ${USER_DIR}/.config/autostart/ desktop_files/zen_notify.desktop
# install -Dm644 -o ${C_USER} -g ${C_USER} -t ${USER_DIR}/.config/autostart/ desktop_files/nvidia-settings-rc.desktop
# install -Dm644 -t ${USER_DIR}/.config/autostart/ desktop_files/zen_notify.desktop
install -Dm644 -t ${USER_DIR}/.config/autostart/ desktop_files/{zen_notify,nvidia-settings-rc}.desktop
## post install
sudo -u "${C_USER}" git log -n1 | grep -E -o "v[0-9]..*" > ${INSTALL_DIR}/zen_version
cp -f ${INSTALL_DIR}/zen_version ${CONF_DIR}/
chown -R ${C_USER}:${C_USER} ${CONF_DIR} ${USER_DIR}/.config/autostart
## restart polkit service
systemctl daemon-reload
systemctl restart polkit.service
echo -e "INSTALL DONE."
# start xtray zenvidia task bar
echo -e "Reload your desktop manager for the system tray task bar refresh or start."
echo -e "Or quit zen_task_menu if already launch and type in a terminal as default user:"
echo -e "zen_notify -z (or -n if driver check only)"
}
make_uninstall(){
rm -Rf ${INSTALL_DIR} ${CONF_DIR}
rm -f ${BIN_DIR}/{zenvidia,zen_notify,zen_start,zen_task_menu,zenvidia-modules-reload}
rm -f ${USER_DIR}/.config/autostart/{zen_notify,nvidia-settings-rc}.desktop
rm -f ${PREFIX}/share/applications/{zenvidia,zenvidia-unpriviledge}.desktop
rm -f ${PREFIX}/share/pixmaps/zen-*.png
rm -Rf ${PREFIX}/share/doc/zenvidia
rm -f /usr/share/polkit-1/actions/com.github.pkexec.zenvidia.policy
rm -f /usr/share/polkit-1/rules.d/com.github.pkexec.zenvidia.rules
echo -e "UNINSTALL DONE."
}
make_safeuninstall(){
rm -f ${BIN_DIR}/{zenvidia,zen_notify,zen_start,zen_task_menu,zenvidia-modules-reload}
rm -f ${USER_DIR}/.config/autostart/{zen_notify,nvidia-settings-rc}.desktop
rm -f ${PREFIX}/share/applications/{zenvidia,zenvidia-unpriviledge}.desktop
rm -f ${PREFIX}/share/pixmaps/zen-*.png
rm -Rf ${PREFIX}/share/doc/zenvidia
rm -f /usr/share/polkit-1/actions/com.github.pkexec.zenvidia.policy
rm -f /usr/share/polkit-1/rules/com.github.pkexec.zenvidia.rules
echo -e "SAFE UNINSTALL DONE."
}
make_update(){
sudo -u ${C_USER} git pull
## system
install -CDm755 -b -t ${BIN_DIR}/ zenvidia zen_notify zen_start zen_task_menu zenvidia-modules-reload
install -CDm644 -b -t ${INSTALL_DIR}/ *.conf
install -Dm644 -t ${INSTALL_DIR}/ README.md
install -Dm644 -t ${PREFIX}/share/applications/ desktop_files/{zenvidia,zenvidia-unpriviledge}.desktop
install -Dm644 -t ${PREFIX}/share/pixmaps/ pixmaps/*.png
install -Dm644 -t ${PREFIX}/share/doc/zenvidia/ docs/*.txt
install -Dm644 -t ${PREFIX}/share/doc/zenvidia/ docs/*.xml
install -Dm644 -t ${PREFIX}/share/doc/zenvidia/ Changelog.txt
install -Dm644 -t /usr/share/polkit-1/actions/ com.github.pkexec.zenvidia.policy
install -Dm644 -t /usr/share/polkit-1/rules.d/ com.github.zenvidia.rules
install -CDm644 -t ${INSTALL_DIR}/locale_dev locale/{Readme_translation.txt,translation_report_helper.sh,translation.pot}
install -CDm644 -t ${INSTALL_DIR}/locale_dev/locale_po locale/locale_dev/*
cp -ruf -t ${INSTALL_DIR}/ locale/locale
# user
install -Dm644 -t ${USER_DIR}/.config/autostart/ desktop_files/{zen_notify,nvidia-settings-rc}.desktop
sudo -u "${C_USER}" git log -n1 | grep -E -o "v[0-9]..*" > ${INSTALL_DIR}/zen_version
cp -f ${INSTALL_DIR}/zen_version ${CONF_DIR}/
chown -R ${C_USER}:${C_USER} ${CONF_DIR}
echo -e "UPDATE DONE."
echo -e "\nCONTROL ZENVIDIA USER CONFIGURATION AFTER FIRST LAUNCH.\n"
echo -e "(user config is automaically control and update at zenvidia start, a little check could be necessary)"
echo -e "Reload your desktop manager for the system tray task bar refresh."
echo -e "Or quit zen_task_menu if already lauch and type in a terminal as default user:"
echo -e "zen_notify -z (or -n if driver check only)"
}
make_help(){
echo -e ${grn}"Command line: $(basename $0 ) [option]"
echo -e "Options are:${cya}"
echo -e " install -> Install fresh."
echo -e " uninstall -> Uninstall and remove all trace."
echo -e " safeuninstall -> Uninstall and keep config and data."
echo -e " update -> Execute git command and update."
echo -e " help -> Display help."
echo -e "${nc}"
}
check_su
if [ $# -gt 0 ]; then
while (( $# > 0 )); do
case ${1} in
install) make_install ;;
uninstall) make_uninstall ;;
safeuninstall) make_safeuninstall ;;
update) make_update ;;
*|help) echo -e "${red}Wrong option${nc}"; make_help ;;
esac
shift
done
else
make_help
fi