-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·245 lines (202 loc) · 8.73 KB
/
install.sh
File metadata and controls
executable file
·245 lines (202 loc) · 8.73 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
# === Colors ===
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# === Settings ===
INSTALL_DIR="$HOME/.local/bin/OdooDeveloperTools"
CONFIG_DIR="$HOME/.ssh/config.d"
FILESTORE_DIR="$HOME/.local/share/Odoo/filestore"
# === Functions ===
check_dependencies() {
echo -e "${BLUE}Checking dependencies...${NC}"
# Check for PostgreSQL client
if ! command -v psql &> /dev/null; then
echo -e "${YELLOW}⚠️ PostgreSQL client not found. Some database tools may not work properly.${NC}"
echo -e " To install PostgreSQL client: sudo apt-get install postgresql-client"
else
echo -e "${GREEN}✓ PostgreSQL client found${NC}"
fi
# Check for SSH
if ! command -v ssh &> /dev/null; then
echo -e "${YELLOW}⚠️ SSH client not found. SSH tools may not work properly.${NC}"
echo -e " To install SSH client: sudo apt-get install openssh-client"
else
echo -e "${GREEN}✓ SSH client found${NC}"
fi
# Check for bc (used for calculations)
if ! command -v bc &> /dev/null; then
echo -e "${YELLOW}⚠️ 'bc' command not found. Some calculations may not work properly.${NC}"
echo -e " To install bc: sudo apt-get install bc"
else
echo -e "${GREEN}✓ bc found${NC}"
fi
}
create_directories() {
echo -e "${BLUE}Creating necessary directories...${NC}"
# Create installation directory
mkdir -p "$INSTALL_DIR"
echo -e "${GREEN}✓ Created $INSTALL_DIR${NC}"
# Create SSH config directory if it doesn't exist
mkdir -p "$CONFIG_DIR"
echo -e "${GREEN}✓ Created $CONFIG_DIR${NC}"
# Create filestore directory if it doesn't exist
mkdir -p "$FILESTORE_DIR"
echo -e "${GREEN}✓ Created $FILESTORE_DIR${NC}"
# Create ~/.local/bin if it doesn't exist
mkdir -p "$HOME/.local/bin"
echo -e "${GREEN}✓ Created $HOME/.local/bin${NC}"
}
install_scripts() {
echo -e "${BLUE}Installing Odoo Developer Tools...${NC}"
# Copy scripts to installation directory
echo -e "${BLUE}Copying scripts to $INSTALL_DIR...${NC}"
cp AddSSHServer "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied AddSSHServer${NC}"
cp ConnectSSHServer "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied ConnectSSHServer${NC}"
cp ListSSHServers "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied ListSSHServers${NC}"
cp ListOdooDatabases "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied ListOdooDatabases${NC}"
cp DropOdooDatabase "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied DropOdooDatabase${NC}"
cp RestoreOdooDatabase "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied RestoreOdooDatabase${NC}"
cp ExtendOdooEnterprise "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied ExtendOdooEnterprise${NC}"
cp OdooDevTools "$INSTALL_DIR/"
echo -e "${GREEN}✓ Copied OdooDevTools${NC}"
# Install dependencies
echo -e "${BLUE}Checking for dependencies...${NC}"
# Detect the Linux distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
elif [ -f /etc/debian_version ]; then
DISTRO="debian"
elif [ -f /etc/fedora-release ]; then
DISTRO="fedora"
elif [ -f /etc/redhat-release ]; then
DISTRO="rhel"
else
DISTRO="unknown"
fi
# Convert to lowercase
DISTRO=$(echo "$DISTRO" | tr '[:upper:]' '[:lower:]')
# Install dialog based on the distribution
if ! command -v dialog &> /dev/null; then
echo -e "${YELLOW}Installing dialog package...${NC}"
case "$DISTRO" in
"ubuntu"|"debian"|"pop"|"mint"|"elementary")
sudo apt-get update -qq && sudo apt-get install -y dialog
;;
"fedora")
sudo dnf install -y dialog
;;
"centos"|"rhel"|"rocky"|"almalinux")
sudo yum install -y dialog
;;
"arch"|"manjaro")
sudo pacman -S --noconfirm dialog
;;
"opensuse"|"suse")
sudo zypper install -y dialog
;;
*)
echo -e "${RED}Could not determine your distribution. Please install 'dialog' manually:${NC}"
echo -e "For Debian/Ubuntu: sudo apt-get install dialog"
echo -e "For Fedora: sudo dnf install dialog"
echo -e "For CentOS/RHEL: sudo yum install dialog"
echo -e "For Arch Linux: sudo pacman -S dialog"
echo -e "For openSUSE: sudo zypper install dialog"
;;
esac
# Check if dialog was installed successfully
if command -v dialog &> /dev/null; then
echo -e "${GREEN}✓ Dialog installed successfully${NC}"
else
echo -e "${YELLOW}Warning: Dialog installation may have failed. The TUI menu may not work.${NC}"
echo -e "${YELLOW}You can still use individual tools directly.${NC}"
fi
else
echo -e "${GREEN}✓ Dialog is already installed${NC}"
fi
# Make scripts executable
echo -e "${BLUE}Adding execute permissions...${NC}"
chmod u+x "$INSTALL_DIR"/*
echo -e "${GREEN}✓ Added execute permissions to all scripts${NC}"
echo -e "${GREEN}✓ Successfully installed scripts to $INSTALL_DIR${NC}"
}
update_path() {
echo -e "${BLUE}Updating PATH in ~/.bashrc...${NC}"
# Check if .bashrc exists
if [[ ! -f "$HOME/.bashrc" ]]; then
echo -e "${YELLOW}⚠️ Could not find .bashrc. Creating it...${NC}"
touch "$HOME/.bashrc"
fi
# Add the directory to PATH if it doesn't already exist in .bashrc
if ! grep -q "export PATH=\"$HOME/.local/bin/OdooDeveloperTools:\$PATH\"" "$HOME/.bashrc"; then
echo -e "\n# Added by Odoo Developer Tools installer" >> "$HOME/.bashrc"
echo "export PATH=\"$HOME/.local/bin/OdooDeveloperTools:\$PATH\"" >> "$HOME/.bashrc"
echo -e "${GREEN}✓ Added $INSTALL_DIR to PATH in ~/.bashrc${NC}"
else
echo -e "${GREEN}✓ $INSTALL_DIR is already in PATH${NC}"
fi
echo -e "${YELLOW}Note: You'll need to restart your terminal or run 'source ~/.bashrc' to update your PATH${NC}"
}
update_ssh_config() {
echo -e "${BLUE}Updating SSH configuration...${NC}"
SSH_CONFIG="$HOME/.ssh/config"
# Create SSH config file if it doesn't exist
if [[ ! -f "$SSH_CONFIG" ]]; then
touch "$SSH_CONFIG"
fi
# Add Include directive if it doesn't exist
if ! grep -q "Include $CONFIG_DIR/\*.conf" "$SSH_CONFIG"; then
echo -e "\n# Include Odoo Developer Tools SSH configurations" >> "$SSH_CONFIG"
echo "Include $CONFIG_DIR/*.conf" >> "$SSH_CONFIG"
echo -e "${GREEN}✓ Updated SSH config to include configurations from $CONFIG_DIR${NC}"
else
echo -e "${GREEN}✓ SSH config already includes configurations from $CONFIG_DIR${NC}"
fi
}
# === Main ===
echo -e "${BLUE}==================================================${NC}"
echo -e "${BLUE} Odoo Developer Tools - Installation Script ${NC}"
echo -e "${BLUE}==================================================${NC}"
# Run installation steps
echo -e "${BLUE}Step 1/5: Checking dependencies...${NC}"
check_dependencies
echo
echo -e "${BLUE}Step 2/5: Creating directories...${NC}"
create_directories
echo
echo -e "${BLUE}Step 3/5: Installing scripts...${NC}"
install_scripts
echo
echo -e "${BLUE}Step 4/5: Updating PATH...${NC}"
update_path
echo
echo -e "${BLUE}Step 5/5: Updating SSH configuration...${NC}"
update_ssh_config
echo
echo -e "${BLUE}==================================================${NC}"
echo -e "${GREEN}✅ Installation complete!${NC}"
echo -e "${YELLOW}Available commands (after restarting terminal or sourcing ~/.bashrc):${NC}"
echo -e " ${GREEN}AddSSHServer${NC} - Add a new SSH server configuration"
echo -e " ${GREEN}ConnectSSHServer${NC} - Connect to a configured SSH server"
echo -e " ${GREEN}ListSSHServers${NC} - List all configured SSH servers"
echo -e " ${GREEN}ListOdooDatabases${NC} - List all local Odoo databases"
echo -e " ${GREEN}DropOdooDatabase${NC} - Remove an Odoo database and its filestore"
echo -e " ${GREEN}RestoreOdooDatabase${NC} - Restore an Odoo database from a backup file"
echo -e " ${GREEN}ExtendOdooEnterprise${NC} - Find and extend Odoo Enterprise databases"
echo -e " ${GREEN}OdooDevTools${NC} - Interactive TUI menu for all tools"
echo -e "${BLUE}==================================================${NC}"
echo -e "${YELLOW}To start using the tools, run: source ~/.bashrc${NC}"
echo -e "${BLUE}==================================================${NC}"