forked from slackjeff/pdvShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·146 lines (122 loc) · 4.02 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·146 lines (122 loc) · 4.02 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
144
145
146
#!/usr/bin/env bash
#sh <(curl -s -L https://raw.githubusercontent.com/voidlinux-br/void-installer/master/install.sh)
#sh <(wget -q -O - https://raw.githubusercontent.com/voidlinux-br/void-installer/master/install.sh)
#source <(curl -s -L https://raw.githubusercontent.com/voidlinux-br/void-installer/master/install.sh)
#source <(wget -q -O - https://raw.githubusercontent.com/voidlinux-br/void-installer/master/install.sh)
# install.sh
# Created: 2023/23/10
# Altered: 2023/23/10
# Updated: seg 27 abr 2026 12:47:01 -04
#
# Copyright (c) 2023-2026, Vilmar Catafesta <vcatafesta@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -euo pipefail
# ===== CORES =====
reset='\033[0m'
rst='\033[0m'
red='\033[1;31m'
green='\033[1;32m'
yellow='\033[1;33m'
blue='\033[1;34m'
oops() {
echo -e "${red}[ERRO]${reset} $*" >&2
exit 1
}
log() {
echo -e "${blue}[*]${reset} $*"
}
ok() {
echo -e " ${green}[OK]${reset} $*"
}
warn() {
echo -e "${yellow}[AVISO]${reset} $*"
}
umask 0022
url='https://raw.githubusercontent.com/slackjeff/pdvShell/refs/heads/main'
files_bin=(pdvshell)
files_home=(LICENSE README.md)
files_lang=(pdvshell)
idioma=(pt_BR en es it de fr ru zh_CN zh_TW ja ko)
tmpDir="$(mktemp -d -t pdvshell.XXXXXX)"
dir_locale="usr/share/locale"
cleanup() {
rm -rf "$tmpDir"
}
trap cleanup EXIT
# downloader
if command -v curl >/dev/null 2>&1; then
cmdfetch() { curl -fsSL "$1" -o "$2"; }
elif command -v wget >/dev/null 2>&1; then
cmdfetch() { wget -q "$1" -O "$2"; }
else
oops "precisa de curl ou wget"
fi
log "usando diretório temporário: $tmpDir"
# download binários
for f in "${files_bin[@]}"; do
log "baixando binário $f..."
cmdfetch "$url/$f" "$tmpDir/$f" || oops "falha ao baixar $f"
ok "$f baixado"
done
# extras
for f in "${files_home[@]}"; do
log "baixando $f..."
cmdfetch "$url/$f" "$tmpDir/$f" || oops "falha ao baixar $f"
done
# locales
for lang in "${idioma[@]}"; do
for f in "${files_lang[@]}"; do
target="$tmpDir/$dir_locale/$lang/LC_MESSAGES"
mkdir -p "$target"
if cmdfetch "$url/$dir_locale/$lang/LC_MESSAGES/$f.mo" "$target/$f.mo"; then
ok "locale $lang"
else
warn "locale $lang não disponível"
fi
done
done
# instala locales
if [[ -d "$tmpDir/usr/share/locale" ]]; then
log "instalando locales..."
sudo cp -r "$tmpDir/usr/share/locale/." /usr/share/locale/
ok "locales instalados"
fi
# instala app
log "instalando em /opt/pdvshell..."
sudo install -d /opt/pdvshell
for file in "${files_bin[@]}"; do
sudo install -m 755 "$tmpDir/$file" "/opt/pdvshell/$file"
ok "$file instalado"
done
# wrapper
log "criando wrapper..."
sudo tee /usr/local/bin/pdvshell >/dev/null <<'EOF'
#!/usr/bin/env bash
cd /opt/pdvshell
exec ./pdvshell "$@"
EOF
sudo chmod 755 /usr/local/bin/pdvshell
ok "wrapper criado"
echo
echo -e "${green}Instalação concluída!${reset}"
echo -e "Use: ${blue}pdvshell${reset}"