-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·154 lines (131 loc) · 5.42 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·154 lines (131 loc) · 5.42 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
#!/bin/bash
# Quick Install Script for Scripts Collection
# Author: @usarral
# Repository: https://github.com/usarral/scripts
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo -e "${BLUE} Scripts Collection - Quick Install${NC}"
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo ""
echo -e "Author: ${CYAN}@usarral${NC}"
echo ""
# Check if running from scripts directory
if [[ ! -f "README.md" ]] || [[ ! -d "disk-management" ]]; then
echo -e "${RED}Error: Please run this script from the scripts directory${NC}"
echo -e "Expected location: ${YELLOW}~/work/scripts/${NC}"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo -e "${YELLOW}Installing from:${NC} $SCRIPT_DIR"
echo ""
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to make scripts executable
make_executable() {
local category=$1
local script_dir=$2
if [[ -d "$SCRIPT_DIR/$category/$script_dir" ]]; then
echo -e "${BLUE}→${NC} Setting up ${GREEN}$script_dir${NC}..."
# Make all .sh files executable
find "$SCRIPT_DIR/$category/$script_dir" -name "*.sh" -type f -exec chmod +x {} \;
local count=$(find "$SCRIPT_DIR/$category/$script_dir" -name "*.sh" -type f | wc -l)
echo -e " ${GREEN}✓${NC} Made $count script(s) executable"
return 0
else
echo -e " ${YELLOW}⊘${NC} Directory not found, skipping"
return 1
fi
}
# Check requirements
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Checking Requirements${NC}"
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo ""
# Check Bash
if command_exists bash; then
BASH_VERSION_NUM=$(bash --version | head -n1 | grep -oE '[0-9]+\.[0-9]+' | head -n1)
echo -e "${GREEN}✓${NC} Bash ${BASH_VERSION_NUM} - OK"
else
echo -e "${RED}✗${NC} Bash - Not found"
exit 1
fi
# Check Git
if command_exists git; then
GIT_VERSION=$(git --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
echo -e "${GREEN}✓${NC} Git ${GIT_VERSION} - OK"
else
echo -e "${YELLOW}⚠${NC} Git - Not found (required for git-repo-cleaner)"
fi
# Check jq
if command_exists jq; then
JQ_VERSION=$(jq --version | grep -oE '[0-9]+\.[0-9]+' | head -n1)
echo -e "${GREEN}✓${NC} jq ${JQ_VERSION} - OK"
else
echo -e "${YELLOW}⚠${NC} jq - Not found (required for restore_repos.sh)"
echo -e " ${CYAN}Install with:${NC} brew install jq"
echo ""
read -p " Install jq now? [y/N]: " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
if command_exists brew; then
echo -e " ${BLUE}Installing jq...${NC}"
brew install jq
if [ $? -eq 0 ]; then
echo -e " ${GREEN}✓${NC} jq installed successfully"
else
echo -e " ${RED}✗${NC} Failed to install jq"
fi
else
echo -e " ${RED}✗${NC} Homebrew not found. Please install jq manually."
fi
fi
fi
echo ""
# Setup scripts
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Setting Up Scripts${NC}"
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo ""
installed_count=0
# Disk Management Scripts
if make_executable "disk-management" "git-repo-cleaner"; then
((installed_count++))
fi
echo ""
# Summary
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Installation Summary${NC}"
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo ""
echo -e "Scripts installed: ${GREEN}$installed_count${NC}"
echo ""
if [[ $installed_count -gt 0 ]]; then
echo -e "${GREEN}✓ Installation complete!${NC}"
echo ""
echo -e "${CYAN}Available Scripts:${NC}"
echo ""
echo -e " ${YELLOW}Git Repository Cleaner${NC}"
echo -e " cd disk-management/git-repo-cleaner"
echo -e " ./free_disk_space.sh"
echo ""
echo -e "${CYAN}Quick Links:${NC}"
echo -e " • Main README: ${YELLOW}cat README.md${NC}"
echo -e " • Structure: ${YELLOW}cat STRUCTURE.md${NC}"
echo -e " • Contributing: ${YELLOW}cat CONTRIBUTING.md${NC}"
else
echo -e "${YELLOW}No scripts found to install${NC}"
fi
echo ""
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
echo ""
echo -e "For more information, visit:"
echo -e "${CYAN}https://github.com/usarral/scripts${NC}"
echo ""