-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (67 loc) · 2.22 KB
/
install.sh
File metadata and controls
executable file
·83 lines (67 loc) · 2.22 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
#!/bin/bash
# Cores para output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${YELLOW}Iniciando instalação do DeepShell...${NC}\n"
# Função para verificar se um comando existe
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Função para instalar pacotes baseado na distribuição
install_package() {
if command_exists apt-get; then
sudo apt-get install -y "$1"
elif command_exists dnf; then
sudo dnf install -y "$1"
elif command_exists pacman; then
sudo pacman -S --noconfirm "$1"
else
echo -e "${RED}Não foi possível identificar o gerenciador de pacotes.${NC}"
exit 1
fi
}
# Verifica e instala Lua
if ! command_exists lua; then
echo -e "${YELLOW}Instalando Lua...${NC}"
install_package lua5.3
install_package liblua5.3-dev
fi
# Verifica e instala LuaRocks
if ! command_exists luarocks; then
echo -e "${YELLOW}Instalando LuaRocks...${NC}"
install_package luarocks
fi
# Instala dependências via LuaRocks
echo -e "${YELLOW}Instalando dependências via LuaRocks...${NC}"
sudo luarocks install luafilesystem
# Cria diretório de instalação
INSTALL_DIR="/usr/local/share/deepshell"
sudo mkdir -p "$INSTALL_DIR"
# Copia os arquivos do shell
echo -e "${YELLOW}Copiando arquivos do DeepShell...${NC}"
sudo cp -r ./* "$INSTALL_DIR/"
# Cria o script executável
EXEC_PATH="/usr/local/bin/deepshell"
echo -e "${YELLOW}Criando executável...${NC}"
cat << EOF | sudo tee "$EXEC_PATH"
#!/bin/bash
exec luajit "$INSTALL_DIR/main.lua" "\$@"
EOF
# Garante as permissões corretas
sudo chmod 755 "$INSTALL_DIR"
sudo chmod 644 "$INSTALL_DIR"/*.lua
sudo chmod 644 "$INSTALL_DIR"/modulos/*.lua
sudo chmod 755 "$EXEC_PATH"
# Cria diretório para histórico e configurações do usuário
mkdir -p "$HOME/.config/deepshell"
touch "$HOME/.deepshell_history"
# Copia arquivo de configuração para o diretório do usuário
cp "$INSTALL_DIR/config.lua" "$HOME/.config/deepshell/config.lua"
# Adiciona o shell à lista de shells válidos
if ! grep -q "$EXEC_PATH" /etc/shells; then
echo "$EXEC_PATH" | sudo tee -a /etc/shells
fi
echo -e "${GREEN}DeepShell foi instalado com sucesso!${NC}"
echo -e "${YELLOW}Digite 'deepshell' para iniciar.${NC}"