-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiger-update
More file actions
91 lines (67 loc) · 2.85 KB
/
tiger-update
File metadata and controls
91 lines (67 loc) · 2.85 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
#!/bin/bash
cd /usr/lib/tiger-os/
function webget(){
local regexp="s/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/\1/;s/%//"
[ -n "${2}" ] && {
wget "${1}" -O "${2}" 2>&1 | sed -u "${regexp}"
return ${?}
}
wget "${1}" 2>&1 | sed -u "${regexp}"
}
mensagem=$(wget -O - https://raw.githubusercontent.com/Tiger-OperatingSystem/feature-update-manager-studio/main/message.txt | sed 's|^| - |g')
[ ! "${?}" = "0" ] && exit # Sem internet
[ -f "/var/tiger-update/version" ] && {
online=$(wget -q "https://github.com/Tiger-OperatingSystem/feature-update-manager-studio/releases/download/continuous/CURRENT" -O -)
[ ! "${?}" = "0" ] && exit # Sem internet
current=$(cat /var/tiger-update/version)
[ "${online}" = "${current}" ] && exit
}
yad --text="\n<b><big>Temos novidades pra você...</big>\n</b>Elas incluem:\n\n${mensagem}\n\n<b>Deseja prosseguir com a instalação?</b>" \
--image=/usr/lib/tiger-os/banner.png --width=800 --center --fixed --button=gtk-yes:0 --button="Depois" --title="Atualização de recursos do Tiger OS"
[ ! "${?}" = "0" ] && {
exit
}
. /usr/lib/tiger-os/tiger-osd.sh
typed_password=""
exit_code=0
sudo -k
failed_message=""
while true; do
typed_password=$(password "Digite sua senha:" "Para instalar atualizações é necessário acesso administrador${failed_message}")
exit_code=${?}
[ ! "${exit_code}" = "0" ] && {
message "Deseja realmente cancelar?" "Caso cancele só amanhã pra você poder instalar de novo" "" yes-no
[ "${?}" = "1" ] && {
typed_password=""
break
}
failed_message="no"
}
[ ! -z "${typed_password}" ] && {
is_passord_ok=$(echo "${typed_password}" | sudo -S echo ok)
[ "${is_passord_ok}" = "ok" ] && {
break
}
failed_message="\n<small>(Senha incorreta)</small>"
} || {
[ "${failed_message}" = "no" ] && {
failed_message=""
} || {
failed_message="\n<small>(Senha é necessária)</small>"
}
}
done
[ -z "${typed_password}" ] && exit
update_file=$(mktemp --dry-run)
webget "https://github.com/Tiger-OperatingSystem/feature-update-manager-studio/releases/download/continuous/tiger-update-package.tgz" "${update_file}" | progress "Baixando as atualizações"
[ ! -f "${update_file}" ] && {
show-error "Ocorreu um erro :(" "Não foi possível baixar o pacote de atualizações"
exit 1
}
if ! tar -tf "${update_file}" &> /dev/null; then
show-error "Ocorreu um erro :(" "Código do erro: $(md5sum ${update_file} | cut -d' ' -f1)"
exit 1
fi
(echo "${typed_password}" | sudo -S tar --same-permissions --same-owner -xvf "${update_file}" -C / ) | pulsate-progress "Instalando..."
yad --text="\n\n\n<b><big>Aproveite as novidades...</big>\n</b>As atualizações foram instaladas com sucesso\n\n" --width=800 --center --fixed --button=gtk-ok --title="Atualização de recursos do Tiger OS" --borders=32
rm ${update_file}