├── .gitattributes
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── README.md
├── TODO.md
├── bootstrap
├── settings.json
├── unix-settings.json
├── version.json
└── w10-settings.json
├── commands
└── yarn-berry.sh
├── configurations
├── alias.sh
├── git
│ ├── alias-git.sh
│ ├── gitconfig.txt
│ └── gitignore.txt
└── ssl.sh
├── install.sh
├── lib
└── utils.sh
├── main.ps1
├── main.sh
├── programs
├── anaconda.sh
├── apache-config.sh
├── apache.sh
├── azurecli.sh
├── bitwarden.ps1
├── ccleaner.ps1
├── configs
│ └── git-config.sh
├── dell-update.ps1
├── discord.ps1
├── docker-compose.sh
├── docker-config.sh
├── docker-desktop.ps1
├── docker.sh
├── dotnet-mono.sh
├── dotnet-nuget.sh
├── dotnet.ps1
├── dotnet.sh
├── dropbox.ps1
├── gcloudcli.sh
├── gcloudsdk.sh
├── geforce-driver.ps1
├── geforce-experience.ps1
├── git.sh
├── github-desktop.ps1
├── golang.sh
├── google-backup-and-sync.ps1
├── herokutoolbelt.sh
├── httrack.ps1
├── hyperv.ps1
├── insomnia.ps1
├── jdk.ps1
├── kubectl.sh
├── kubernetes-helm.sh
├── megasync.ps1
├── mongo.sh
├── mosh.sh
├── mysql-phpmyadmin.sh
├── mysql.sh
├── netkit.sh
├── nginx.sh
├── nvm-config.sh
├── nvm.sh
├── pgadmin.ps1
├── php-composer.sh
├── php-laravel.sh
├── php.sh
├── pip-beautysh.sh
├── polar.ps1
├── postgre-pgadmin.sh
├── postgre-postgis.sh
├── postgre.sh
├── powershell.sh
├── protobuf.sh
├── pyenv-virtualenv.sh
├── pyenv.sh
├── python-pip.sh
├── python3.sh
├── qbittorrent.ps1
├── redis.sh
├── rlang.sh
├── rstudio.sh
├── ruby-jekyll.sh
├── rvm-config.sh
├── rvm.sh
├── sharex.ps1
├── shellcheck.sh
├── shfmt.sh
├── spotify.ps1
├── ssh.sh
├── station.ps1
├── steam.ps1
├── tools-and-services
│ ├── chkinstall.sh
│ ├── disable-ads.ps1
│ └── localtunnel-service.sh
├── vagrant.sh
├── vlc.ps1
├── vscode.ps1
├── vscode.sh
├── wsl.ps1
├── x11server.sh
├── yarn-leasot.sh
├── yarn-localtunnel.sh
├── yarn-prettier.sh
└── yarn-strapi.sh
├── remote-install.ps1
├── remote-install.sh
└── scaffolding
└── ex new program
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text eol=lf
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore docs files
2 | _gh_pages
3 | _site
4 | .ruby-version
5 |
6 | # Numerous always-ignore extensions
7 | *.diff
8 | *.err
9 | *.log
10 | *.orig
11 | *.rej
12 | *.swo
13 | *.swp
14 | *.vi
15 | *.zip
16 | *~
17 |
18 | # OS or Editor folders
19 | ._*
20 | .cache
21 | .DS_Store
22 | .idea
23 | .project
24 | .settings
25 | .tmproj
26 | *.esproj
27 | *.sublime-project
28 | *.sublime-workspace
29 | nbproject
30 | Thumbs.db
31 |
32 | # Komodo
33 | .komodotools
34 | *.komodoproject
35 |
36 | # grunt-html-validation
37 | validation-report.json
38 | validation-status.json
39 |
40 | # Folders to ignore
41 | bower_components
42 | node_modules
43 | LICENSE
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@gatti.pl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matbrgz/dotfiles/1117bb018b46b02f44c2c4dd2685d083f7caca20/CONTRIBUTING.md
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | # Dotfiles TODO & Progress
2 |
3 | ## ✅ Completed (v2.0)
4 |
5 | ### Global Improvements
6 | - [x] ~~Merge Windows and Linux config JSON~~ → Created unified `settings.json`
7 | - [x] ~~Improve JSON schema~~ → Comprehensive schema with categories, presets, and install methods
8 | - [x] Modern shell script architecture with error handling
9 | - [x] Universal package manager detection (apt, pacman, yay, dnf, zypper, snap, flatpak, brew)
10 | - [x] Colored logging system with different log levels
11 | - [x] Modular design with separate utility library
12 | - [x] Automatic backup system for configurations
13 | - [x] Interactive installation with multiple modes
14 | - [x] Support for preset installations
15 | - [x] Personal settings configuration system
16 |
17 | ### Shell Script Improvements
18 | - [x] Created comprehensive utility library (`lib/utils.sh`)
19 | - [x] Modern error handling with `set -euo pipefail`
20 | - [x] Automatic OS and package manager detection
21 | - [x] Improved logging with timestamps and colors
22 | - [x] JSON processing with error handling
23 | - [x] Modular program installation scripts
24 | - [x] Configuration-only scripts separated from installation
25 |
26 | ### System Detection & Compatibility
27 | - [x] Multi-distribution support (Ubuntu, Debian, Arch, Fedora, openSUSE)
28 | - [x] WSL (Windows Subsystem for Linux) detection
29 | - [x] Package manager auto-detection and fallback
30 | - [x] Architecture detection (x86_64, arm64)
31 |
32 | ### Program Scripts Modernization (NEW)
33 | - [x] Git installation and configuration
34 | - [x] Docker installation with multi-distro support
35 | - [x] **Node.js/NVM installation script** - Complete with NVM support, global packages, aliases, and project templates
36 | - [x] **Python3 and pyenv configuration** - Complete with pyenv support, virtual environments, and development tools
37 |
38 | ## 🚧 In Progress
39 |
40 | ### Configuration System
41 | - [ ] Dotfiles synchronization (vim, tmux, bash configs)
42 | - [ ] SSH key management and GitHub integration
43 | - [ ] Development environment variables setup
44 | - [ ] Shell aliases and functions installation
45 |
46 | ### Program Scripts Modernization (Continued)
47 | - [ ] VS Code installation and extension setup
48 | - [ ] Apache/Nginx web server setup
49 | - [ ] PHP with Composer installation
50 | - [ ] MySQL/PostgreSQL setup
51 |
52 | ## 📋 TODO - High Priority
53 |
54 | ### Core System Improvements
55 | - [ ] **PowerShell version for Windows** - Native Windows support
56 | - [ ] **Configuration validation** - Validate settings.json before installation
57 | - [ ] **Dependency resolution** - Handle program dependencies automatically
58 | - [ ] **Rollback system** - Ability to uninstall/rollback changes
59 | - [ ] **Parallel installations** - Install multiple programs simultaneously
60 | - [ ] **Installation resume** - Resume interrupted installations
61 |
62 | ### Program Installation Scripts
63 | - [ ] **Development tools**
64 | - [ ] VS Code with extensions
65 | - [ ] JetBrains IDEs
66 | - [ ] Terminal emulators (Alacritty, Kitty)
67 | - [ ] **Web development**
68 | - [ ] PHP with composer
69 | - [ ] MySQL/PostgreSQL setup
70 | - [ ] Redis configuration
71 | - [ ] Nginx with SSL setup
72 |
73 | ### Desktop Applications
74 | - [ ] **Browsers**
75 | - [ ] Chrome with extensions
76 | - [ ] Firefox with addons
77 | - [ ] Brave browser
78 | - [ ] **Communication**
79 | - [ ] Discord
80 | - [ ] Slack
81 | - [ ] Telegram
82 | - [ ] **Media**
83 | - [ ] Spotify
84 | - [ ] VLC
85 | - [ ] OBS Studio
86 | - [ ] **Productivity**
87 | - [ ] LibreOffice
88 | - [ ] GIMP
89 | - [ ] Blender
90 |
91 | ## 📋 TODO - Medium Priority
92 |
93 | ### Advanced Features
94 | - [ ] **Cloud synchronization** - Sync settings across machines
95 | - [ ] **Encrypted secrets management** - Store API keys, tokens securely
96 | - [ ] **Machine profiles** - Different setups for different machine types
97 | - [ ] **Plugin system** - Allow community plugins
98 | - [ ] **GUI installer** - Electron-based graphical installer
99 | - [ ] **Remote installation** - Install over SSH
100 | - [ ] **Docker containerized installer** - Run installer in container
101 |
102 | ### DevOps & Infrastructure
103 | - [ ] **Kubernetes tools**
104 | - [ ] kubectl configuration
105 | - [ ] Helm setup
106 | - [ ] k9s terminal UI
107 | - [ ] **Cloud CLI tools**
108 | - [ ] AWS CLI
109 | - [ ] Azure CLI
110 | - [ ] Google Cloud SDK
111 | - [ ] **Infrastructure as Code**
112 | - [ ] Terraform
113 | - [ ] Ansible
114 | - [ ] Pulumi
115 | - [ ] **Monitoring tools**
116 | - [ ] Prometheus
117 | - [ ] Grafana
118 | - [ ] ELK stack
119 |
120 | ### Documentation & Testing
121 | - [ ] **Comprehensive documentation**
122 | - [ ] API documentation for utils.sh
123 | - [ ] Contributing guidelines
124 | - [ ] Script writing guide
125 | - [ ] **Testing framework**
126 | - [ ] Unit tests for utility functions
127 | - [ ] Integration tests for installations
128 | - [ ] CI/CD pipeline with GitHub Actions
129 | - [ ] **Example configurations**
130 | - [ ] Sample dotfiles
131 | - [ ] Template projects
132 | - [ ] Best practices guide
133 |
134 | ## 📋 TODO - Low Priority
135 |
136 | ### Quality of Life Improvements
137 | - [ ] **Installation analytics** - Anonymous usage statistics
138 | - [ ] **Update checker** - Check for dotfiles updates
139 | - [ ] **Configuration wizard** - Interactive setup for beginners
140 | - [ ] **Performance monitoring** - Installation time optimization
141 | - [ ] **Bandwidth optimization** - Cache downloads locally
142 | - [ ] **Offline mode** - Install from local packages
143 |
144 | ### Platform Support
145 | - [ ] **Android Termux** - Mobile development environment
146 |
147 | ### Integration Features
148 | - [ ] **GitHub integration** - Auto-fork dotfiles repo
149 | - [ ] **Backup to cloud** - Google Drive, Dropbox sync
150 | - [ ] **Team synchronization** - Share configs with team
151 | - [ ] **Enterprise features** - Company-wide configurations
152 |
153 | ## 🐛 Known Issues
154 |
155 | ### Current Bugs
156 | - [ ] Some package managers require manual GPG key import
157 | - [ ] WSL2 Docker integration needs additional setup
158 | - [ ] Snap packages may conflict with APT packages
159 | - [ ] Git SSH key generation doesn't handle existing keys well
160 |
161 | ### Compatibility Issues
162 | - [ ] Old distributions may not have recent package versions
163 | - [ ] ARM64 architecture support is limited for some packages
164 | - [ ] Some snap packages are not available on all distributions
165 |
166 | ## 🎯 Version Goals
167 |
168 | ### v2.1 - Enhanced Core Features
169 | - [ ] Complete program modernization
170 | - [ ] PowerShell Windows version
171 | - [ ] Configuration validation system
172 | - [ ] Dependency resolution
173 |
174 | ### v2.2 - Advanced Automation
175 | - [ ] Parallel installation support
176 | - [ ] Cloud synchronization
177 | - [ ] Plugin system
178 | - [ ] GUI installer
179 |
180 | ### v3.0 - Enterprise Ready
181 | - [ ] Team/enterprise features
182 | - [ ] Advanced security
183 | - [ ] Centralized management
184 | - [ ] Comprehensive testing
185 |
186 | ---
187 |
188 | ## 📊 Progress Summary
189 |
190 | - **✅ Completed**: 19 major items
191 | - **🚧 In Progress**: 5 items
192 | - **📋 High Priority**: 19 items
193 | - **📋 Medium Priority**: 20 items
194 | - **📋 Low Priority**: 15 items
195 |
196 | **Total Progress**: ~24% complete towards full vision
197 |
198 | ### Recent Accomplishments (v2.1)
199 | - ✅ Created comprehensive Node.js/NVM installation script with templates
200 | - ✅ Created comprehensive Python/pyenv installation script with templates
201 | - ✅ Created comprehensive VS Code installation script with extensions and configuration
202 | - ✅ Enhanced project structure with modern script templates
203 | - ✅ Implemented development environment setup automation
204 |
205 | *Last updated: $(date +%Y-%m-%d)*
206 | *Maintainer: matbrgz*
--------------------------------------------------------------------------------
/bootstrap/unix-settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "personal": {
3 | "name": "Matheus Rocha Vieira",
4 | "email": "matheusrv@email.com",
5 | "githubuser": "MatheusRV",
6 | "defaultfolder": "/mnt/d/Cloud/GitHub"
7 | },
8 | "programs": [
9 | {
10 | "program": "ssh",
11 | "name": "Secure Shell (SSH)",
12 | "installation": "true",
13 | "default": false
14 | },
15 | {
16 | "program": "protobuf",
17 | "name": "Google Protobuf",
18 | "installation": "false",
19 | "default": false
20 | },
21 | {
22 | "program": "azurecli",
23 | "name": "Azure Comand-line Interface",
24 | "installation": "false",
25 | "default": false
26 | },
27 | {
28 | "program": "herokucli",
29 | "name": "Heroku Comand-line Interface",
30 | "installation": "false",
31 | "default": false
32 | },
33 | {
34 | "program": "gcloudcli",
35 | "name": "Google Cloud Comand-line Interface",
36 | "installation": "false",
37 | "default": false
38 | },
39 | {
40 | "program": "gcloudsdk",
41 | "name": "Google Cloud Software Development Kit",
42 | "installation": "false",
43 | "default": false
44 | },
45 | {
46 | "program": "rlang",
47 | "name": "R Lang",
48 | "installation": "true",
49 | "default": false
50 | },
51 | {
52 | "program": "rstudio",
53 | "name": "RStudio",
54 | "installation": "false",
55 | "default": false,
56 | "dependencies": "rlang"
57 | },
58 | {
59 | "program": "powershell",
60 | "name": "PowerShell",
61 | "installation": "false",
62 | "default": false
63 | },
64 | {
65 | "program": "dotnet",
66 | "name": "dotNet",
67 | "installation": "false",
68 | "default": false
69 | },
70 | {
71 | "program": "dotnetnuget",
72 | "name": "dotNet nuGet",
73 | "installation": "false",
74 | "default": false,
75 | "dependencies": "dotnet"
76 | },
77 | {
78 | "program": "dotnetmono",
79 | "name": "dotNet Mono",
80 | "installation": "false",
81 | "default": false,
82 | "dependencies": "dotnet"
83 | },
84 | {
85 | "program": "apache",
86 | "name": "Apache",
87 | "installation": "true",
88 | "default": false,
89 | "config": true,
90 | "port": "8080"
91 | },
92 | {
93 | "program": "nginx",
94 | "name": "Nginx",
95 | "installation": "false",
96 | "default": false
97 | },
98 | {
99 | "program": "php",
100 | "name": "PHP Hypertext Preprocessor",
101 | "installation": "true",
102 | "default": false
103 | },
104 | {
105 | "program": "php-composer",
106 | "name": "PHP Composer",
107 | "installation": "false",
108 | "default": false,
109 | "dependencies": "php"
110 | },
111 | {
112 | "program": "php-laravel",
113 | "name": "Laravel",
114 | "installation": "false",
115 | "default": false,
116 | "dependencies": "php"
117 | },
118 | {
119 | "program": "mysql",
120 | "name": "MySQL",
121 | "installation": "false",
122 | "default": false
123 | },
124 | {
125 | "program": "mysql-phpmyadmin",
126 | "name": "phpMyAdmin",
127 | "installation": "false",
128 | "default": false,
129 | "dependencies": "mysql"
130 | },
131 | {
132 | "program": "postgre",
133 | "name": "Postgre",
134 | "installation": "false",
135 | "default": false
136 | },
137 | {
138 | "program": "postgre-postgis",
139 | "name": "PostGIS",
140 | "installation": "false",
141 | "default": false,
142 | "dependencies": "postgre"
143 | },
144 | {
145 | "program": "postgre-pgadmin",
146 | "name": "pgAdmin",
147 | "installation": "false",
148 | "default": false,
149 | "dependencies": "postgre"
150 | },
151 | {
152 | "program": "mongo",
153 | "name": "MongoDB",
154 | "installation": "true",
155 | "default": false
156 | },
157 | {
158 | "program": "redis",
159 | "name": "Redis",
160 | "installation": "false",
161 | "default": false
162 | },
163 | {
164 | "program": "nvm",
165 | "name": "Node Version Manager",
166 | "installation": "true",
167 | "default": false,
168 | "config": true
169 | },
170 | {
171 | "program": "yarn-strapi",
172 | "name": "Strapi",
173 | "installation": "false",
174 | "default": false,
175 | "dependencies": "nvm"
176 | },
177 | {
178 | "program": "yarn-localtunnel",
179 | "name": "LocalTunnel",
180 | "installation": "false",
181 | "default": false,
182 | "dependencies": "nvm",
183 | "hostname": "matheusrv1",
184 | "port": "60000"
185 | },
186 | {
187 | "program": "yarn-prettier",
188 | "name": "Prettier",
189 | "installation": "false",
190 | "default": false,
191 | "dependencies": "nvm"
192 | },
193 | {
194 | "program": "yarn-leasot",
195 | "name": "Leasot",
196 | "installation": "false",
197 | "default": false,
198 | "dependencies": "nvm"
199 | },
200 | {
201 | "program": "anaconda",
202 | "name": "Anaconda",
203 | "installation": "true",
204 | "default": false
205 | },
206 | {
207 | "program": "python3",
208 | "name": "Python3",
209 | "installation": "true",
210 | "default": false
211 | },
212 | {
213 | "program": "python-pip",
214 | "name": "Python PIP",
215 | "installation": "true",
216 | "default": false,
217 | "dependencies": "python3"
218 | },
219 | {
220 | "program": "pip-beautysh",
221 | "name": "Beautysh",
222 | "installation": "false",
223 | "default": false,
224 | "dependencies": "python-pip"
225 | },
226 | {
227 | "program": "pyenv",
228 | "name": "Python Virtual Env",
229 | "installation": "false",
230 | "default": false
231 | },
232 | {
233 | "program": "pyenv-virtualenv",
234 | "name": "Python Env Virtual Env",
235 | "installation": "false",
236 | "default": false,
237 | "dependencies": "pyenv"
238 | },
239 | {
240 | "program": "golang",
241 | "name": "GoLang",
242 | "installation": "true",
243 | "default": false
244 | },
245 | {
246 | "program": "rvm",
247 | "name": "Ruby Version Manager",
248 | "installation": "true",
249 | "default": false,
250 | "config": true
251 | },
252 | {
253 | "program": "ruby-jekyll",
254 | "name": "Jekyll",
255 | "installation": "false",
256 | "default": false,
257 | "dependencies": "rvm"
258 | },
259 | {
260 | "program": "vagrant",
261 | "name": "Vagrant",
262 | "installation": "true",
263 | "default": false
264 | },
265 | {
266 | "program": "docker",
267 | "name": "Docker",
268 | "installation": "true",
269 | "default": false,
270 | "config": true
271 | },
272 | {
273 | "program": "docker-compose",
274 | "name": "Docker Compose",
275 | "installation": "false",
276 | "default": true
277 | },
278 | {
279 | "program": "kubectl",
280 | "name": "Kubernetes",
281 | "installation": "false",
282 | "default": false
283 | },
284 | {
285 | "program": "kubernetes-helm",
286 | "name": "Kubernetes Helm",
287 | "installation": "false",
288 | "default": false,
289 | "dependencies": "kubectl"
290 | },
291 | {
292 | "program": "mosh",
293 | "name": "Mosh",
294 | "installation": "false",
295 | "default": false
296 | },
297 | {
298 | "program": "shfmt",
299 | "name": "shfmt",
300 | "installation": "false",
301 | "default": false
302 | },
303 | {
304 | "program": "shellcheck",
305 | "name": "ShellCheck",
306 | "installation": "true",
307 | "default": false
308 | },
309 | {
310 | "program": "x11server",
311 | "name": "X11 Server",
312 | "installation": "true",
313 | "default": false
314 | },
315 | {
316 | "program": "netkit",
317 | "name": "NetKit",
318 | "installation": "false",
319 | "default": false
320 | }
321 | ],
322 | "configurations": {
323 | "debug": "true",
324 | "purge": "false"
325 | }
326 | }
--------------------------------------------------------------------------------
/bootstrap/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "docker_compose": "2.36.2",
3 | "kubectl": "1.32.0",
4 | "helm": "3.16.4",
5 | "nvm": "0.40.1",
6 | "ruby": "3.3.6",
7 | "golang": "1.23.4",
8 | "terraform": "1.10.4",
9 | "mongodb": "8.0.4",
10 | "php": "8.4.2",
11 | "node": "22.12.0",
12 | "postgresql": "17.2.0",
13 | "python": "3.13.1",
14 | "python_pip": "24.3.1",
15 | "java": "23",
16 | "dotnet": "9.0.101",
17 | "mysql": "9.1.0",
18 | "redis": "7.4.1",
19 | "apache": "2.4.62",
20 | "nginx": "1.27.3",
21 | "docker": "28.1.0",
22 | "ansible": "11.1.0",
23 | "vagrant": "2.4.2",
24 | "azurecli": "2.69.0",
25 | "gcloudsdk": "507.0.0",
26 | "powershell": "7.4.6",
27 | "git": "2.47.1",
28 | "vscode": "1.96.2",
29 | "chrome": "132.0.6834",
30 | "firefox": "134.0.2",
31 | "discord": "0.0.78",
32 | "spotify": "1.2.54",
33 | "vlc": "3.0.21",
34 | "steam": "3.5.5",
35 | "qbittorrent": "5.0.2",
36 | "bitwarden": "2024.12.3",
37 | "dropbox": "212.4.4867",
38 | "megasync": "5.6.0.0",
39 | "protobuf": "29.2",
40 | "vim": "9.1.0",
41 | "curl": "8.11.1",
42 | "wget": "1.25.0",
43 | "htop": "3.3.0",
44 | "tmux": "3.5a",
45 | "ssh": "9.9p1",
46 | "shellcheck": "0.10.0",
47 | "mosh": "1.4.0",
48 | "unzip": "6.0.2",
49 | "buildx": "0.24.0",
50 | "buildkit": "0.22.0",
51 | "containerd": "2.1.0",
52 | "anaconda": "2024.10-1",
53 | "pyenv": "2.4.22",
54 | "rvm": "1.29.12",
55 | "composer": "2.8.5",
56 | "laravel": "11.0",
57 | "insomnia": "10.2.0",
58 | "shfmt": "3.10.0",
59 | "netkit": "0.17",
60 | "x11server": "21.1.14"
61 | }
62 |
--------------------------------------------------------------------------------
/bootstrap/w10-settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "programs": [
3 | {
4 | "program": "geforce-experience",
5 | "name": "GeForce Experience",
6 | "installation": true,
7 | "default": true
8 | },
9 | {
10 | "program": "geforce-driver",
11 | "name": "GeForce Game Ready Driver",
12 | "installation": true,
13 | "default": true
14 | },
15 | {
16 | "program": "docker-desktop",
17 | "name": "Docker Desktop",
18 | "installation": true,
19 | "default": true
20 | },
21 | {
22 | "program": "dotnet",
23 | "name": "dotNet Framework 3.5 (include dotNet 2.5 and 3.0)",
24 | "installation": true,
25 | "default": true
26 | },
27 | {
28 | "program": "github-desktop",
29 | "name": "GitHub Desktop",
30 | "installation": true,
31 | "default": true
32 | },
33 | {
34 | "program": "vscode",
35 | "name": "VSCode",
36 | "installation": true,
37 | "default": true
38 | },
39 | {
40 | "program": "hyperv",
41 | "name": "Hyper-V",
42 | "installation": true,
43 | "default": true
44 | },
45 | {
46 | "program": "insomnia",
47 | "name": "Insomnia REST API Client",
48 | "installation": false,
49 | "default": true
50 | },
51 | {
52 | "program": "jdk8",
53 | "name": "Java Development Kit 8",
54 | "installation": false,
55 | "default": false
56 | },
57 | {
58 | "program": "wsl",
59 | "name": "Windows Linux Subsystem (Ubuntu 18.04)",
60 | "installation": false,
61 | "default": true
62 | },
63 | {
64 | "program": "pgadmin",
65 | "name": "pgAdmin",
66 | "installation": false,
67 | "default": false
68 | },
69 | {
70 | "program": "httrack",
71 | "name": "HTTrack",
72 | "installation": true,
73 | "default": false
74 | },
75 | {
76 | "program": "bitwarden",
77 | "name": "BitWarden",
78 | "installation": true,
79 | "default": false
80 | },
81 | {
82 | "program": "ccleaner",
83 | "name": "CCleaner",
84 | "installation": true,
85 | "default": false
86 | },
87 | {
88 | "program": "polar",
89 | "name": "Polar Bookshelf",
90 | "installation": true,
91 | "default": false
92 | },
93 | {
94 | "program": "qbittorrent",
95 | "name": "qBitorrent",
96 | "installation": true,
97 | "default": false
98 | },
99 | {
100 | "program": "sharex",
101 | "name": "ShareX",
102 | "installation": true,
103 | "default": false
104 | },
105 | {
106 | "program": "station",
107 | "name": "Station",
108 | "installation": true,
109 | "default": false
110 | },
111 | {
112 | "program": "vlc",
113 | "name": "VLC Media Player",
114 | "installation": true,
115 | "default": false
116 | },
117 | {
118 | "program": "spotify",
119 | "name": "Spotify",
120 | "installation": false,
121 | "default": false
122 | },
123 | {
124 | "program": "discord",
125 | "name": "Discord",
126 | "installation": true,
127 | "default": false
128 | },
129 | {
130 | "program": "steam",
131 | "name": "Steam",
132 | "installation": true,
133 | "default": false
134 | },
135 | {
136 | "program": "google-backup-and-sync",
137 | "name": "Google Backup and Sync",
138 | "installation": true,
139 | "default": true
140 | },
141 | {
142 | "program": "dropbox",
143 | "name": "Dropbox",
144 | "installation": true,
145 | "default": true
146 | },
147 | {
148 | "program": "megasync",
149 | "name": "Mega",
150 | "installation": true,
151 | "default": true
152 | },
153 | {
154 | "program": "dell-update",
155 | "name": "Dell Update",
156 | "installation": true,
157 | "default": true
158 | }
159 | ]
160 | }
--------------------------------------------------------------------------------
/commands/yarn-berry.sh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matbrgz/dotfiles/1117bb018b46b02f44c2c4dd2685d083f7caca20/commands/yarn-berry.sh
--------------------------------------------------------------------------------
/configurations/alias.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | defaultfolder="$(jq -r '.personal.defaultfolder' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
9 | echo "
10 | # ls aliases
11 | alias la=\"ls -al\"
12 | alias ls=\"ls -h --color --group-directories-first\" # flat view w/ directories first
13 | alias l=\"ls -h --color --group-directories-first\" # same as above
14 | alias ll=\"ls -lv --group-directories-first\" # non-flat view
15 | alias lm=\"ll | more\"
16 |
17 | # Folder alias
18 | alias hdir=\"cd ${HOME}\"
19 | alias homedir=\"cd ${HOME}\"
20 | # shellcheck disable=SC2139
21 | alias wdir=\"cd ${defaultfolder}\"
22 |
23 | # Quick parent-directory aliases
24 | alias ..=\"cd ..\"
25 | alias ...=\"cd ../..\"
26 | alias .4=\"cd ../../..\"
27 | alias .5=\"cd ../../../..\"
28 | alias .6=\"cd ../../../../..\"
29 | alias .7=\"cd ../../../../../..\"
30 | alias .8=\"cd ../../../../../../..\"
31 | alias .9=\"cd ../../../../../../../..\"
32 |
33 | # File and Folder Permission
34 | alias mx=\"chmod a+x\"
35 | alias 000=\"chmod 000\"
36 | alias 644=\"chmod 644\"
37 | alias 755=\"chmod 755\"
38 | alias 777=\"chmod 777\"
39 |
40 | # Others
41 | alias editbash=\"nano ${HOME}/.bashrc\"
42 | alias editba=\"nano ${HOME}/.bash_aliases\"
43 | alias resource=\"source ${HOME}/.bashrc\"
44 | alias hosts=\"nano /mnt/c/Windows/System32/drivers/etc/hosts\"
45 | alias code=\"code .\"
46 | alias np=\"cmd.exe /c notepad\"
47 |
48 | #NetWork
49 | alias ip=\"curl ipinfo.io/ip\"
50 | alias ips=\"ifconfig -a | perl -nle'/(\d+.\d+.\d+.\d+)/ && print \$1'\"
51 | alias speedtest=\"wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test100.zip\"
52 |
53 | # Handy Extract Program
54 | function extract()
55 | {
56 | if [ -f \$1 ] ; then
57 | case \$1 in
58 | *.tar.bz2) tar xvjf \$1 ;;
59 | *.tar.gz) tar xvzf \$1 ;;
60 | *.bz2) bunzip2 \$1 ;;
61 | *.rar) unrar x \$1 ;;
62 | *.gz) gunzip \$1 ;;
63 | *.tar) tar xvf \$1 ;;
64 | *.tbz2) tar xvjf \$1 ;;
65 | *.tgz) tar xvzf \$1 ;;
66 | *.zip) unzip \$1 ;;
67 | *.Z) uncompress \$1 ;;
68 | *.7z) 7z x \$1 ;;
69 | *) echo \"'\$1' cannot be extracted via >extract<\" ;;
70 | esac
71 | else
72 | echo \"'\$1' is not a valid file!\"
73 | fi
74 | }
75 |
76 |
77 | # Make Dir and CD to it
78 | function mcd ()
79 | {
80 | mkdir -p \$1
81 | cd \$1
82 | }
83 |
84 | # Switch a File or Folder
85 | function swap()
86 | {
87 | if [ ! -z \"\$2\" ] && [ -e \"\$1\" ] && [ -e \"\$2\" ] && ! [ \"\$1\" -ef \"\$2\" ] && (([ -f \"\$1\" ] && [ -f \"\$2\" ]) || ([ -d \"\$1\" ] && [ -d \"\$2\" ])) ; then
88 | tmp=$(mktemp -d $(dirname \"\$1\")/XXXXXX)
89 | mv \"\$1\" \"\$tmp\" && mv \"\$2\" \"\$1\" && mv \"\$tmp\"/\"\$1\" \"\$2\"
90 | rmdir \"\$tmp\"
91 | else
92 | echo \"Usage: swap file1 file2 or swap dir1 dir2\"
93 | fi
94 | }
95 |
96 | # Creates an archive (*.tar.gz) from given directory.
97 | function maketar() { tar cvzf \"\${1%%/}.tar.gz\" \"\${1%%/}/\"; }
98 |
99 | # Create a ZIP archive of a file or folder.
100 | function makezip() { zip -r \"\${1%%/}.zip\" \"\$1\" ; }
101 |
102 | # Make your directories and files access rights sane.
103 | function sanitize() { chmod -R u=rwX,g=rX,o= \"\$@\" ;}
104 |
105 | cd ${defaultfolder}
106 | " >>"${HOME}"/.bash_aliases
107 |
108 | if [[ ! "$(uname -r)" =~ "Microsoft$" ]]; then
109 | {
110 | # Alias to run Windows cmd.exe from WSL
111 | alias cmd="/mnt/c/Windows/System32/cmd.exe"
112 | alias cmdc="/mnt/c/Windows/System32/cmd.exe /c"
113 | } >>"${HOME}"/.bash_aliases
114 | fi
115 |
--------------------------------------------------------------------------------
/configurations/git/alias-git.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | {
9 | # Get the Git branch
10 | parse_git_branch() {
11 | git branch 2>/dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/ (\1)/"
12 | }
13 |
14 | # Make Git branch a variable
15 | branch="$(git branch | sed -n -e "s/^\* \(.*\)/\1/p")"
16 |
17 | # Git commands
18 | alias log="git log"
19 | alias wut='git log master...${branch} --oneline'
20 | alias diff="git diff"
21 | alias branch="git branch"
22 | alias status="git status"
23 | alias st="git status"
24 | alias fetch="git fetch"
25 | alias push="git push origin head"
26 | alias pull="git pull"
27 | alias fp="fetch && pull"
28 | alias gmm="git merge master"
29 | alias recent="git for-each-ref --sort=-committerdate refs/heads/"
30 | alias branch_new="git for-each-ref --sort=-committerdate refs/heads/ --format=%(refname:short)"
31 | alias add="git add -A"
32 | alias gac="git add -A && git commit"
33 | alias gsur="git submodule update --remote"
34 | alias glf="git ls-files"
35 | alias gl="git log --graph --pretty=oneline --abbrev-commit --decorate"
36 |
37 | ## Git branch switching
38 | alias master="git co master"
39 | alias ghp="git co gh-pages"
40 |
41 | # Others
42 | alias editgit="nano ~/.gitconfig"
43 | } >>"${HOME}"/./bashrc
44 |
--------------------------------------------------------------------------------
/configurations/git/gitconfig.txt:
--------------------------------------------------------------------------------
1 | [user]
2 | name = Matheus Rocha Vieira
3 | email = matheusrv@email.com
4 | signingkey = KEY_ID
5 |
6 | [commit]
7 | gpgsign = true
8 |
9 | [gpg]
10 | program = /usr/local/bin/gpg
11 |
12 | [alias]
13 | co = checkout
14 | cp = cherry-pick
15 | ci = commit
16 | st = status
17 | br = branch
18 |
19 | [color]
20 | ui = auto
21 | [color "branch"]
22 | current = yellow reverse
23 | local = yellow
24 | remote = green
25 | [color "diff"]
26 | meta = yellow
27 | frag = magenta
28 | old = red
29 | new = green
30 | whitespace = red reverse
31 | [color "status"]
32 | added = yellow
33 | changed = green
34 | untracked = cyan
35 | [core]
36 | whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
37 |
--------------------------------------------------------------------------------
/configurations/git/gitignore.txt:
--------------------------------------------------------------------------------
1 | # Ignore docs files
2 | _gh_pages
3 | _site
4 | .ruby-version
5 |
6 | # Numerous always-ignore extensions
7 | *.diff
8 | *.err
9 | *.log
10 | *.orig
11 | *.rej
12 | *.swo
13 | *.swp
14 | *.vi
15 | *.zip
16 | *~
17 |
18 | # OS or Editor folders
19 | ._*
20 | .cache
21 | .DS_Store
22 | .idea
23 | .project
24 | .settings
25 | .tmproj
26 | *.esproj
27 | *.sublime-project
28 | *.sublime-workspace
29 | nbproject
30 | Thumbs.db
31 |
32 | # Komodo
33 | .komodotools
34 | *.komodoproject
35 |
36 | # grunt-html-validation
37 | validation-report.json
38 | validation-status.json
39 |
40 | # Folders to ignore
41 | bower_components
42 | node_modules
43 |
--------------------------------------------------------------------------------
/configurations/ssl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | email=$(jq -r '.personal.email' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)
9 | ssh-keygen -t rsa -b 4096 -C "$email"
10 | eval "$(ssh-agent -s)"
11 | ssh-add ~/.ssh/id_rsa
12 | #https://help.github.com/en/enterprise/2.16/user/articles/adding-a-new-ssh-key-to-your-github-account
13 |
--------------------------------------------------------------------------------
/lib/utils.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # DOTFILES UTILITY LIBRARY
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Core utility functions for system detection and package management
8 | # =============================================================================
9 |
10 | # Global variables
11 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
13 | SETTINGS_FILE="$PROJECT_ROOT/settings.json"
14 |
15 | # Colors for output
16 | RED='\033[0;31m'
17 | GREEN='\033[0;32m'
18 | YELLOW='\033[1;33m'
19 | BLUE='\033[0;34m'
20 | PURPLE='\033[0;35m'
21 | CYAN='\033[0;36m'
22 | NC='\033[0m' # No Color
23 |
24 | # =============================================================================
25 | # LOGGING FUNCTIONS
26 | # =============================================================================
27 |
28 | log_info() {
29 | echo -e "${BLUE}[INFO]${NC} $1"
30 | }
31 |
32 | log_success() {
33 | echo -e "${GREEN}[SUCCESS]${NC} $1"
34 | }
35 |
36 | log_warning() {
37 | echo -e "${YELLOW}[WARNING]${NC} $1"
38 | }
39 |
40 | log_error() {
41 | echo -e "${RED}[ERROR]${NC} $1"
42 | }
43 |
44 | log_debug() {
45 | if [[ "${DEBUG_MODE:-false}" == "true" ]]; then
46 | echo -e "${PURPLE}[DEBUG]${NC} $1"
47 | fi
48 | }
49 |
50 | log_step() {
51 | echo -e "${CYAN}[STEP]${NC} $1"
52 | }
53 |
54 | # =============================================================================
55 | # SYSTEM DETECTION FUNCTIONS
56 | # =============================================================================
57 |
58 | detect_os() {
59 | local os_type=""
60 |
61 | if [[ "$OSTYPE" == "linux-gnu"* ]]; then
62 | if grep -q Microsoft /proc/version 2>/dev/null; then
63 | os_type="wsl"
64 | else
65 | os_type="linux"
66 | fi
67 | elif [[ "$OSTYPE" == "darwin"* ]]; then
68 | os_type="macos"
69 | elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
70 | os_type="windows"
71 | else
72 | os_type="unknown"
73 | fi
74 |
75 | echo "$os_type"
76 | }
77 |
78 | detect_distro() {
79 | local distro=""
80 |
81 | if [[ -f /etc/os-release ]]; then
82 | distro=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | tr -d '"')
83 | elif [[ -f /etc/lsb-release ]]; then
84 | distro=$(grep "DISTRIB_ID" /etc/lsb-release | cut -d'=' -f2 | tr -d '"')
85 | elif command -v lsb_release >/dev/null 2>&1; then
86 | distro=$(lsb_release -si | tr '[:upper:]' '[:lower:]')
87 | else
88 | distro="unknown"
89 | fi
90 |
91 | echo "$distro"
92 | }
93 |
94 | detect_package_manager() {
95 | local pm=""
96 |
97 | # Check for package managers in order of preference
98 | if command -v yay >/dev/null 2>&1; then
99 | pm="yay"
100 | elif command -v pacman >/dev/null 2>&1; then
101 | pm="pacman"
102 | elif command -v apt >/dev/null 2>&1; then
103 | pm="apt"
104 | elif command -v dnf >/dev/null 2>&1; then
105 | pm="dnf"
106 | elif command -v zypper >/dev/null 2>&1; then
107 | pm="zypper"
108 | elif command -v brew >/dev/null 2>&1; then
109 | pm="brew"
110 | elif command -v snap >/dev/null 2>&1; then
111 | pm="snap"
112 | elif command -v flatpak >/dev/null 2>&1; then
113 | pm="flatpak"
114 | else
115 | pm="unknown"
116 | fi
117 |
118 | echo "$pm"
119 | }
120 |
121 | get_system_info() {
122 | local os_type distro package_manager
123 |
124 | os_type=$(detect_os)
125 | distro=$(detect_distro)
126 | package_manager=$(detect_package_manager)
127 |
128 | cat << EOF
129 | {
130 | "os": "$os_type",
131 | "distro": "$distro",
132 | "package_manager": "$package_manager",
133 | "kernel": "$(uname -r)",
134 | "architecture": "$(uname -m)",
135 | "hostname": "$(hostname)"
136 | }
137 | EOF
138 | }
139 |
140 | # =============================================================================
141 | # PACKAGE MANAGEMENT FUNCTIONS
142 | # =============================================================================
143 |
144 | update_package_manager() {
145 | local pm="$1"
146 |
147 | log_step "Updating package manager: $pm"
148 |
149 | case "$pm" in
150 | "apt")
151 | sudo apt update && sudo apt upgrade -y
152 | ;;
153 | "pacman")
154 | sudo pacman -Syu --noconfirm
155 | ;;
156 | "yay")
157 | yay -Syu --noconfirm
158 | ;;
159 | "dnf")
160 | sudo dnf update -y
161 | ;;
162 | "zypper")
163 | sudo zypper update -y
164 | ;;
165 | "brew")
166 | brew update && brew upgrade
167 | ;;
168 | "snap")
169 | sudo snap refresh
170 | ;;
171 | "flatpak")
172 | flatpak update -y
173 | ;;
174 | *)
175 | log_warning "Unknown package manager: $pm"
176 | return 1
177 | ;;
178 | esac
179 | }
180 |
181 | install_package() {
182 | local pm="$1"
183 | local package="$2"
184 |
185 | log_step "Installing $package using $pm"
186 |
187 | case "$pm" in
188 | "apt")
189 | sudo apt install -y $package
190 | ;;
191 | "pacman")
192 | sudo pacman -S --noconfirm $package
193 | ;;
194 | "yay")
195 | yay -S --noconfirm $package
196 | ;;
197 | "dnf")
198 | sudo dnf install -y $package
199 | ;;
200 | "zypper")
201 | sudo zypper install -y $package
202 | ;;
203 | "brew")
204 | brew install $package
205 | ;;
206 | "snap")
207 | sudo snap install $package
208 | ;;
209 | "flatpak")
210 | flatpak install -y $package
211 | ;;
212 | *)
213 | log_error "Unknown package manager: $pm"
214 | return 1
215 | ;;
216 | esac
217 | }
218 |
219 | remove_package() {
220 | local pm="$1"
221 | local package="$2"
222 |
223 | log_step "Removing $package using $pm"
224 |
225 | case "$pm" in
226 | "apt")
227 | sudo apt remove -y $package && sudo apt autoremove -y
228 | ;;
229 | "pacman")
230 | sudo pacman -Rs --noconfirm $package
231 | ;;
232 | "yay")
233 | yay -Rs --noconfirm $package
234 | ;;
235 | "dnf")
236 | sudo dnf remove -y $package
237 | ;;
238 | "zypper")
239 | sudo zypper remove -y $package
240 | ;;
241 | "brew")
242 | brew uninstall $package
243 | ;;
244 | "snap")
245 | sudo snap remove $package
246 | ;;
247 | "flatpak")
248 | flatpak uninstall -y $package
249 | ;;
250 | *)
251 | log_error "Unknown package manager: $pm"
252 | return 1
253 | ;;
254 | esac
255 | }
256 |
257 | check_package_installed() {
258 | local pm="$1"
259 | local package="$2"
260 |
261 | case "$pm" in
262 | "apt")
263 | dpkg -l | grep -qw "$package"
264 | ;;
265 | "pacman"|"yay")
266 | pacman -Qi "$package" >/dev/null 2>&1
267 | ;;
268 | "dnf")
269 | dnf list installed | grep -qw "$package"
270 | ;;
271 | "zypper")
272 | zypper se -i | grep -qw "$package"
273 | ;;
274 | "brew")
275 | brew list | grep -qw "$package"
276 | ;;
277 | "snap")
278 | snap list | grep -qw "$package"
279 | ;;
280 | "flatpak")
281 | flatpak list | grep -qw "$package"
282 | ;;
283 | *)
284 | log_error "Unknown package manager: $pm"
285 | return 1
286 | ;;
287 | esac
288 | }
289 |
290 | # =============================================================================
291 | # JSON PROCESSING FUNCTIONS
292 | # =============================================================================
293 |
294 | get_json_value() {
295 | local json_file="$1"
296 | local key="$2"
297 |
298 | if command -v jq >/dev/null 2>&1; then
299 | jq -r "$key" "$json_file" 2>/dev/null || echo "null"
300 | else
301 | log_error "jq is required for JSON processing"
302 | return 1
303 | fi
304 | }
305 |
306 | set_json_value() {
307 | local json_file="$1"
308 | local key="$2"
309 | local value="$3"
310 |
311 | if command -v jq >/dev/null 2>&1; then
312 | local temp_file=$(mktemp)
313 | jq "$key = \"$value\"" "$json_file" > "$temp_file" && mv "$temp_file" "$json_file"
314 | else
315 | log_error "jq is required for JSON processing"
316 | return 1
317 | fi
318 | }
319 |
320 | get_program_config() {
321 | local program="$1"
322 | local config_key="$2"
323 |
324 | get_json_value "$SETTINGS_FILE" ".programs.${program}.${config_key}"
325 | }
326 |
327 | is_program_enabled() {
328 | local program="$1"
329 | local enabled=$(get_program_config "$program" "enabled")
330 | [[ "$enabled" == "true" ]]
331 | }
332 |
333 | get_install_method() {
334 | local program="$1"
335 | local pm="$2"
336 |
337 | get_json_value "$SETTINGS_FILE" ".programs.${program}.install_methods.${pm}"
338 | }
339 |
340 | # =============================================================================
341 | # FILE SYSTEM FUNCTIONS
342 | # =============================================================================
343 |
344 | ensure_directory() {
345 | local dir="$1"
346 |
347 | if [[ ! -d "$dir" ]]; then
348 | log_step "Creating directory: $dir"
349 | mkdir -p "$dir"
350 | fi
351 | }
352 |
353 | backup_file() {
354 | local file="$1"
355 | local backup_dir="${PROJECT_ROOT}/backups/$(date +%Y%m%d_%H%M%S)"
356 |
357 | if [[ -f "$file" ]]; then
358 | ensure_directory "$backup_dir"
359 | cp "$file" "$backup_dir/"
360 | log_info "Backed up $file to $backup_dir/"
361 | fi
362 | }
363 |
364 | # =============================================================================
365 | # VALIDATION FUNCTIONS
366 | # =============================================================================
367 |
368 | validate_settings() {
369 | if [[ ! -f "$SETTINGS_FILE" ]]; then
370 | log_error "Settings file not found: $SETTINGS_FILE"
371 | return 1
372 | fi
373 |
374 | if ! jq . "$SETTINGS_FILE" >/dev/null 2>&1; then
375 | log_error "Invalid JSON in settings file: $SETTINGS_FILE"
376 | return 1
377 | fi
378 |
379 | log_success "Settings file validated successfully"
380 | return 0
381 | }
382 |
383 | check_dependencies() {
384 | local deps=("jq" "curl" "wget")
385 | local missing_deps=()
386 |
387 | for dep in "${deps[@]}"; do
388 | if ! command -v "$dep" >/dev/null 2>&1; then
389 | missing_deps+=("$dep")
390 | fi
391 | done
392 |
393 | if [[ ${#missing_deps[@]} -gt 0 ]]; then
394 | log_error "Missing dependencies: ${missing_deps[*]}"
395 | log_info "Please install the missing dependencies and try again"
396 | return 1
397 | fi
398 |
399 | return 0
400 | }
401 |
402 | # =============================================================================
403 | # INITIALIZATION FUNCTION
404 | # =============================================================================
405 |
406 | init_utils() {
407 | # Set debug mode from settings
408 | local debug_mode=$(get_json_value "$SETTINGS_FILE" ".system.behavior.debug_mode")
409 | if [[ "$debug_mode" == "true" ]]; then
410 | export DEBUG_MODE=true
411 | set -x
412 | fi
413 |
414 | # Validate environment
415 | validate_settings || exit 1
416 | check_dependencies || exit 1
417 |
418 | log_info "Utils library initialized successfully"
419 | }
420 |
421 | # =============================================================================
422 | # EXPORT FUNCTIONS
423 | # =============================================================================
424 |
425 | # This script is meant to be sourced, so we don't run anything automatically
426 | # unless it's being executed directly
427 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
428 | # Script is being run directly, show system info
429 | echo "System Information:"
430 | get_system_info | jq .
431 | fi
--------------------------------------------------------------------------------
/programs/apache-config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | APACHE_VERSION="$(jq -r '.APACHE_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
9 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
10 | sudo apt -y purge apache"${APACHE_VERSION}"*
11 | fi
12 | echo " [ DOING ] Apache: Default Dev folder as initial directory on localhost"
13 | port="$(jq -r '.programs[] | select(.program=="apache").port' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
14 | defaultfolder="$(jq -r '.personal.defaultfolder' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
15 | if [ -d /var/www ]; then
16 | sudo rm -f -R /var/www
17 | fi
18 | sudo rm -f /etc/apache"${APACHE_VERSION}"/sites-available/000-default.conf
19 | sudo echo "
20 | ServerAdmin webmaster@localhost
21 | DocumentRoot ${defaultfolder}
22 |
23 |
24 | Options Indexes FollowSymLinks MultiViews
25 | AllowOverride All
26 | Require all granted
27 |
28 |
29 | #LogLevel info ssl:warn
30 | ErrorLog ${APACHE_LOG_DIR}/error.log
31 | CustomLog ${APACHE_LOG_DIR}/access.log combined
32 | " | sudo tee -a /etc/apache"${APACHE_VERSION}"/sites-available/000-default.conf
33 | if [ "${port}" != 80 ]; then
34 | sudo sed -i "/Listen 80/c\Listen ${port}" /etc/apache2/ports.conf
35 | fi
36 | sudo /etc/init.d/apache"${APACHE_VERSION}" stop
37 | echo " [ DOING ] Apache: Allowing mod rewrite rules"
38 | sudo a2enmod rewrite
39 | sudo /etc/init.d/apache"${APACHE_VERSION}" start
40 | echo " [ DOING ] Apache: Allow autoindex for editing apache directory listing"
41 | sudo a2enmod autoindex
42 | sudo service apache2 restart || sudo service apache2 start
43 |
--------------------------------------------------------------------------------
/programs/apache.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | APACHE_VERSION="$(jq -r '.APACHE_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
9 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
10 | sudo apt -y purge apache"${APACHE_VERSION}"*
11 | fi
12 | sudo apt -y install apache"${APACHE_VERSION}"
13 | dpkg --get-selections | grep apache
--------------------------------------------------------------------------------
/programs/bitwarden.ps1:
--------------------------------------------------------------------------------
1 | cinst -y bitwarden
--------------------------------------------------------------------------------
/programs/ccleaner.ps1:
--------------------------------------------------------------------------------
1 | cinst -y github-desktop
--------------------------------------------------------------------------------
/programs/configs/git-config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # GIT CONFIGURATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Configure Git with personalized settings
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | main() {
19 | log_info "Starting Git configuration"
20 |
21 | # Get personal settings
22 | local name email
23 | name=$(get_json_value "$PROJECT_ROOT/settings.json" ".personal.name")
24 | email=$(get_json_value "$PROJECT_ROOT/settings.json" ".personal.email")
25 |
26 | if [[ "$name" == "null" || "$email" == "null" ]]; then
27 | log_warning "Personal name or email not set in settings.json"
28 | log_info "Please update your personal information in settings.json"
29 | return 1
30 | fi
31 |
32 | # Run Git configuration from the main Git script
33 | bash "$PROJECT_ROOT/programs/git.sh"
34 |
35 | log_success "Git configuration completed"
36 | }
37 |
38 | # Run main function if script is executed directly
39 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
40 | main "$@"
41 | fi
--------------------------------------------------------------------------------
/programs/dell-update.ps1:
--------------------------------------------------------------------------------
1 | cinst -y dellcommandupdate
--------------------------------------------------------------------------------
/programs/discord.ps1:
--------------------------------------------------------------------------------
1 | cinst -y discord.install
--------------------------------------------------------------------------------
/programs/docker-compose.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # DOCKER COMPOSE INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Docker Compose
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_docker_compose() {
19 | log_step "Installing Docker Compose"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing Docker Compose installation"
27 | sudo rm -f /usr/local/bin/docker-compose
28 | sudo rm -f /usr/bin/docker-compose
29 | fi
30 |
31 | # Check if Docker Compose plugin is already available
32 | if docker compose version >/dev/null 2>&1; then
33 | log_info "Docker Compose plugin is already available"
34 | return 0
35 | fi
36 |
37 | # Try package manager first
38 | case "$pm" in
39 | "apt")
40 | sudo apt update
41 | sudo apt install -y docker-compose-plugin 2>/dev/null || install_docker_compose_standalone
42 | ;;
43 | "pacman")
44 | sudo pacman -S --noconfirm docker-compose 2>/dev/null || install_docker_compose_standalone
45 | ;;
46 | "yay")
47 | yay -S --noconfirm docker-compose 2>/dev/null || install_docker_compose_standalone
48 | ;;
49 | "dnf")
50 | sudo dnf install -y docker-compose-plugin 2>/dev/null || install_docker_compose_standalone
51 | ;;
52 | "zypper")
53 | sudo zypper install -y docker-compose 2>/dev/null || install_docker_compose_standalone
54 | ;;
55 | "snap")
56 | sudo snap install docker 2>/dev/null || install_docker_compose_standalone
57 | ;;
58 | "brew")
59 | brew install docker-compose 2>/dev/null || install_docker_compose_standalone
60 | ;;
61 | *)
62 | install_docker_compose_standalone
63 | ;;
64 | esac
65 |
66 | log_success "Docker Compose installed successfully"
67 | }
68 |
69 | install_docker_compose_standalone() {
70 | log_step "Installing Docker Compose standalone binary"
71 |
72 | local architecture
73 | local os_type
74 | local compose_version
75 |
76 | architecture=$(uname -m)
77 | os_type=$(uname -s)
78 |
79 | # Get latest version from GitHub API
80 | compose_version=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')
81 |
82 | if [[ -z "$compose_version" ]]; then
83 | log_warning "Could not determine latest Docker Compose version, using v2.20.0"
84 | compose_version="v2.20.0"
85 | fi
86 |
87 | log_info "Installing Docker Compose $compose_version"
88 |
89 | # Download and install
90 | local download_url="https://github.com/docker/compose/releases/download/${compose_version}/docker-compose-${os_type}-${architecture}"
91 |
92 | if curl -L "$download_url" -o /tmp/docker-compose; then
93 | sudo mv /tmp/docker-compose /usr/local/bin/docker-compose
94 | sudo chmod +x /usr/local/bin/docker-compose
95 |
96 | # Create symlink for convenience
97 | sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose 2>/dev/null || true
98 |
99 | log_success "Docker Compose standalone binary installed"
100 | else
101 | log_error "Failed to download Docker Compose"
102 | return 1
103 | fi
104 | }
105 |
106 | setup_bash_completion() {
107 | log_step "Setting up bash completion for Docker Compose"
108 |
109 | local completion_dir="/etc/bash_completion.d"
110 |
111 | if [[ -d "$completion_dir" ]]; then
112 | # Docker Compose completion
113 | if [[ ! -f "$completion_dir/docker-compose" ]]; then
114 | sudo curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/bash/docker-compose -o "$completion_dir/docker-compose" 2>/dev/null || true
115 | fi
116 |
117 | log_success "Bash completion configured"
118 | else
119 | log_warning "Bash completion directory not found, skipping"
120 | fi
121 | }
122 |
123 | verify_installation() {
124 | log_step "Verifying Docker Compose installation"
125 |
126 | # Check Docker Compose plugin
127 | if docker compose version >/dev/null 2>&1; then
128 | local compose_version
129 | compose_version=$(docker compose version)
130 | log_success "Docker Compose plugin version: $compose_version"
131 | return 0
132 | fi
133 |
134 | # Check standalone Docker Compose
135 | if command -v docker-compose >/dev/null 2>&1; then
136 | local compose_version
137 | compose_version=$(docker-compose --version)
138 | log_success "Docker Compose standalone version: $compose_version"
139 | return 0
140 | fi
141 |
142 | log_error "Docker Compose installation verification failed"
143 | return 1
144 | }
145 |
146 | main() {
147 | log_info "Starting Docker Compose setup"
148 |
149 | # Check if Docker is installed
150 | if ! command -v docker >/dev/null 2>&1; then
151 | log_warning "Docker is not installed. Installing Docker first..."
152 | if [[ -f "$PROJECT_ROOT/programs/docker.sh" ]]; then
153 | "$PROJECT_ROOT/programs/docker.sh"
154 | else
155 | log_error "Docker installation script not found"
156 | return 1
157 | fi
158 | fi
159 |
160 | install_docker_compose
161 | setup_bash_completion
162 | verify_installation
163 |
164 | log_success "Docker Compose setup completed successfully"
165 | }
166 |
167 | # Run main function if script is executed directly
168 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
169 | main "$@"
170 | fi
171 |
--------------------------------------------------------------------------------
/programs/docker-config.sh:
--------------------------------------------------------------------------------
1 | sudo groupadd docker || true
2 | sudo usermod -aG docker "${USER}" || true
3 | docker -H localhost:2375 images
4 | echo "export DOCKER_HOST=\"tcp://0.0.0.0:2375\"" >>"${HOME}"/.bashrc
--------------------------------------------------------------------------------
/programs/docker-desktop.ps1:
--------------------------------------------------------------------------------
1 | cinst -y docker-desktop
--------------------------------------------------------------------------------
/programs/docker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # DOCKER INSTALLATION AND CONFIGURATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure Docker with automatic distro detection
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_docker_apt() {
19 | log_step "Installing Docker via APT"
20 |
21 | # Remove old versions
22 | sudo apt remove -y docker docker-engine docker.io containerd runc 2>/dev/null || true
23 |
24 | # Update packages
25 | sudo apt update
26 |
27 | # Install dependencies
28 | sudo apt install -y \
29 | apt-transport-https \
30 | ca-certificates \
31 | curl \
32 | gnupg \
33 | lsb-release
34 |
35 | # Add Docker's official GPG key
36 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
37 |
38 | # Set up the stable repository
39 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
40 |
41 | # Install Docker Engine
42 | sudo apt update
43 | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
44 |
45 | log_success "Docker installed via APT"
46 | }
47 |
48 | install_docker_pacman() {
49 | log_step "Installing Docker via Pacman"
50 |
51 | sudo pacman -S --noconfirm docker docker-compose
52 |
53 | log_success "Docker installed via Pacman"
54 | }
55 |
56 | install_docker_yay() {
57 | log_step "Installing Docker via YAY"
58 |
59 | yay -S --noconfirm docker docker-compose
60 |
61 | log_success "Docker installed via YAY"
62 | }
63 |
64 | install_docker_dnf() {
65 | log_step "Installing Docker via DNF"
66 |
67 | # Remove old versions
68 | sudo dnf remove -y docker \
69 | docker-client \
70 | docker-client-latest \
71 | docker-common \
72 | docker-latest \
73 | docker-latest-logrotate \
74 | docker-logrotate \
75 | docker-engine 2>/dev/null || true
76 |
77 | # Install dependencies
78 | sudo dnf install -y dnf-plugins-core
79 |
80 | # Add Docker repository
81 | sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
82 |
83 | # Install Docker
84 | sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
85 |
86 | log_success "Docker installed via DNF"
87 | }
88 |
89 | install_docker() {
90 | log_step "Installing Docker"
91 |
92 | local pm distro
93 | pm=$(detect_package_manager)
94 | distro=$(detect_distro)
95 |
96 | case "$pm" in
97 | "apt")
98 | install_docker_apt
99 | ;;
100 | "pacman")
101 | install_docker_pacman
102 | ;;
103 | "yay")
104 | install_docker_yay
105 | ;;
106 | "dnf")
107 | install_docker_dnf
108 | ;;
109 | "snap")
110 | sudo snap install docker
111 | ;;
112 | *)
113 | log_error "Unsupported package manager: $pm"
114 | log_info "Please install Docker manually for your system"
115 | return 1
116 | ;;
117 | esac
118 |
119 | # Start and enable Docker service
120 | sudo systemctl start docker
121 | sudo systemctl enable docker
122 |
123 | log_success "Docker installation completed"
124 | }
125 |
126 | configure_docker() {
127 | log_step "Configuring Docker"
128 |
129 | # Add user to docker group
130 | if ! groups "$USER" | grep -q docker; then
131 | sudo usermod -aG docker "$USER"
132 | log_success "Added $USER to docker group"
133 | log_warning "Please logout and login again for group changes to take effect"
134 | else
135 | log_info "User $USER is already in docker group"
136 | fi
137 |
138 | # Configure Docker daemon
139 | local docker_config_dir="/etc/docker"
140 | local daemon_config="$docker_config_dir/daemon.json"
141 |
142 | sudo mkdir -p "$docker_config_dir"
143 |
144 | # Create daemon configuration
145 | sudo tee "$daemon_config" > /dev/null << 'EOF'
146 | {
147 | "log-driver": "json-file",
148 | "log-opts": {
149 | "max-size": "10m",
150 | "max-file": "3"
151 | },
152 | "storage-driver": "overlay2",
153 | "dns": ["8.8.8.8", "8.8.4.4"],
154 | "default-address-pools": [
155 | {
156 | "base": "172.80.0.0/12",
157 | "size": 24
158 | }
159 | ]
160 | }
161 | EOF
162 |
163 | log_success "Docker daemon configured"
164 |
165 | # Restart Docker to apply configuration
166 | sudo systemctl restart docker
167 |
168 | log_success "Docker service restarted"
169 | }
170 |
171 | install_docker_compose() {
172 | log_step "Installing Docker Compose"
173 |
174 | # Check if Docker Compose is already installed via plugin
175 | if docker compose version >/dev/null 2>&1; then
176 | log_info "Docker Compose plugin is already installed"
177 | return 0
178 | fi
179 |
180 | # Install standalone Docker Compose if plugin is not available
181 | local compose_version
182 | compose_version=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')
183 |
184 | if [[ -z "$compose_version" ]]; then
185 | log_warning "Could not determine latest Docker Compose version, using v2.20.0"
186 | compose_version="v2.20.0"
187 | fi
188 |
189 | log_info "Installing Docker Compose $compose_version"
190 |
191 | sudo curl -L "https://github.com/docker/compose/releases/download/${compose_version}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
192 | sudo chmod +x /usr/local/bin/docker-compose
193 |
194 | # Create symlink for convenience
195 | sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose 2>/dev/null || true
196 |
197 | log_success "Docker Compose installed successfully"
198 | }
199 |
200 | setup_bash_completion() {
201 | log_step "Setting up bash completion"
202 |
203 | local completion_dir="/etc/bash_completion.d"
204 |
205 | if [[ -d "$completion_dir" ]]; then
206 | # Docker completion
207 | if [[ ! -f "$completion_dir/docker" ]]; then
208 | sudo curl -L https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o "$completion_dir/docker"
209 | fi
210 |
211 | # Docker Compose completion
212 | if [[ ! -f "$completion_dir/docker-compose" ]]; then
213 | sudo curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/bash/docker-compose -o "$completion_dir/docker-compose"
214 | fi
215 |
216 | log_success "Bash completion configured"
217 | else
218 | log_warning "Bash completion directory not found, skipping"
219 | fi
220 | }
221 |
222 | verify_installation() {
223 | log_step "Verifying Docker installation"
224 |
225 | # Check Docker version
226 | if command -v docker >/dev/null 2>&1; then
227 | local docker_version
228 | docker_version=$(docker --version)
229 | log_success "Docker version: $docker_version"
230 | else
231 | log_error "Docker command not found"
232 | return 1
233 | fi
234 |
235 | # Check Docker Compose version
236 | if docker compose version >/dev/null 2>&1; then
237 | local compose_version
238 | compose_version=$(docker compose version)
239 | log_success "Docker Compose version: $compose_version"
240 | elif command -v docker-compose >/dev/null 2>&1; then
241 | local compose_version
242 | compose_version=$(docker-compose --version)
243 | log_success "Docker Compose version: $compose_version"
244 | else
245 | log_warning "Docker Compose not found"
246 | fi
247 |
248 | # Check Docker service status
249 | if systemctl is-active --quiet docker; then
250 | log_success "Docker service is running"
251 | else
252 | log_warning "Docker service is not running"
253 | fi
254 |
255 | log_success "Docker verification completed"
256 | }
257 |
258 | create_docker_alias() {
259 | log_step "Creating useful Docker aliases"
260 |
261 | local bashrc="$HOME/.bashrc"
262 | local aliases_section="# Docker aliases added by matbrgz dotfiles"
263 |
264 | # Check if aliases already exist
265 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
266 | log_info "Docker aliases already exist in $bashrc"
267 | return 0
268 | fi
269 |
270 | # Add Docker aliases
271 | cat >> "$bashrc" << 'EOF'
272 |
273 | # Docker aliases added by matbrgz dotfiles
274 | alias d='docker'
275 | alias dc='docker compose'
276 | alias dps='docker ps'
277 | alias dpsa='docker ps -a'
278 | alias di='docker images'
279 | alias dex='docker exec -it'
280 | alias dlog='docker logs'
281 | alias dlogf='docker logs -f'
282 | alias drm='docker rm'
283 | alias drmi='docker rmi'
284 | alias dstop='docker stop'
285 | alias dstart='docker start'
286 | alias drestart='docker restart'
287 | alias dclean='docker system prune -f'
288 | alias dcleanall='docker system prune -a -f'
289 | alias dvol='docker volume ls'
290 | alias dnet='docker network ls'
291 | EOF
292 |
293 | log_success "Docker aliases added to $bashrc"
294 | log_info "Run 'source ~/.bashrc' or start a new shell to use the aliases"
295 | }
296 |
297 | main() {
298 | log_info "Starting Docker setup"
299 |
300 | # Check if Docker is already installed
301 | if command -v docker >/dev/null 2>&1; then
302 | log_info "Docker is already installed"
303 | else
304 | install_docker
305 | fi
306 |
307 | configure_docker
308 | install_docker_compose
309 | setup_bash_completion
310 | create_docker_alias
311 | verify_installation
312 |
313 | log_success "Docker setup completed successfully"
314 |
315 | # Show next steps
316 | echo
317 | log_info "Next steps:"
318 | echo " 1. Logout and login again to apply group changes"
319 | echo " 2. Test Docker with: docker run hello-world"
320 | echo " 3. Use 'source ~/.bashrc' to load new aliases"
321 | }
322 |
323 | # Run main function if script is executed directly
324 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
325 | main "$@"
326 | fi
327 |
--------------------------------------------------------------------------------
/programs/dotnet-mono.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | RELEASE_VERSION="$(lsb_release -cs)"
9 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
10 | sudo apt -y purge mono*
11 | fi
12 | sudo echo "deb https://download.mono-project.com/repo/ubuntu stable-${RELEASE_VERSION} main" |
13 | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
14 | sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
15 | sudo apt -qq update
16 | sudo apt -y install mono-devel
17 | dpkg --get-selections | grep mono
18 |
--------------------------------------------------------------------------------
/programs/dotnet-nuget.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
9 | echo "NuGet purge not implemented yet! Skipping."
10 | fi
11 | if ! curl /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe; then
12 | echo "NuGet Download failed! Exiting."
13 | kill $$
14 | fi
15 | sudo chmod 755 /usr/local/bin/nuget.exe
16 |
--------------------------------------------------------------------------------
/programs/dotnet.ps1:
--------------------------------------------------------------------------------
1 | #Enable DotNet3.5
2 | Enable-WindowsOptionalFeature -Online -FeatureName NetFx3
3 |
--------------------------------------------------------------------------------
/programs/dropbox.ps1:
--------------------------------------------------------------------------------
1 | cinst -y dropbox
--------------------------------------------------------------------------------
/programs/gcloudcli.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 |
--------------------------------------------------------------------------------
/programs/geforce-driver.ps1:
--------------------------------------------------------------------------------
1 | cinst -y geforce-game-ready-driver
--------------------------------------------------------------------------------
/programs/geforce-experience.ps1:
--------------------------------------------------------------------------------
1 | cinst -y geforce-experience
--------------------------------------------------------------------------------
/programs/git.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # GIT INSTALLATION AND CONFIGURATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure Git with modern settings
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_git() {
19 | log_step "Installing Git"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | case "$pm" in
25 | "apt")
26 | sudo apt update && sudo apt install -y git git-lfs
27 | ;;
28 | "pacman")
29 | sudo pacman -S --noconfirm git git-lfs
30 | ;;
31 | "yay")
32 | yay -S --noconfirm git git-lfs
33 | ;;
34 | "dnf")
35 | sudo dnf install -y git git-lfs
36 | ;;
37 | "zypper")
38 | sudo zypper install -y git git-lfs
39 | ;;
40 | "brew")
41 | brew install git git-lfs
42 | ;;
43 | *)
44 | log_error "Unsupported package manager: $pm"
45 | return 1
46 | ;;
47 | esac
48 |
49 | log_success "Git installed successfully"
50 | }
51 |
52 | configure_git() {
53 | log_step "Configuring Git"
54 |
55 | # Get personal settings
56 | local name email
57 | name=$(get_json_value "$PROJECT_ROOT/settings.json" ".personal.name")
58 | email=$(get_json_value "$PROJECT_ROOT/settings.json" ".personal.email")
59 |
60 | if [[ "$name" == "null" || "$email" == "null" ]]; then
61 | log_warning "Personal name or email not set in settings.json"
62 | return 1
63 | fi
64 |
65 | # Basic configuration
66 | git config --global user.name "$name"
67 | git config --global user.email "$email"
68 |
69 | # Modern Git settings
70 | git config --global init.defaultBranch main
71 | git config --global pull.rebase false
72 | git config --global push.default simple
73 | git config --global core.autocrlf input
74 | git config --global core.safecrlf warn
75 | git config --global core.editor "vim"
76 |
77 | # Enhanced diff and merge settings
78 | git config --global diff.tool vimdiff
79 | git config --global merge.tool vimdiff
80 | git config --global difftool.prompt false
81 |
82 | # Color settings
83 | git config --global color.ui auto
84 | git config --global color.branch auto
85 | git config --global color.diff auto
86 | git config --global color.status auto
87 |
88 | # Useful aliases
89 | git config --global alias.st status
90 | git config --global alias.co checkout
91 | git config --global alias.br branch
92 | git config --global alias.ci commit
93 | git config --global alias.unstage 'reset HEAD --'
94 | git config --global alias.last 'log -1 HEAD'
95 | git config --global alias.visual '!gitk'
96 | git config --global alias.graph 'log --oneline --graph --decorate --all'
97 | git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
98 |
99 | # Performance settings
100 | git config --global core.preloadindex true
101 | git config --global core.fscache true
102 | git config --global gc.auto 256
103 |
104 | # Initialize Git LFS
105 | git lfs install
106 |
107 | log_success "Git configured successfully"
108 | log_info "User: $name <$email>"
109 | }
110 |
111 | setup_ssh_key() {
112 | log_step "Setting up SSH key for Git"
113 |
114 | local email
115 | email=$(get_json_value "$PROJECT_ROOT/settings.json" ".personal.email")
116 |
117 | if [[ "$email" == "null" ]]; then
118 | log_warning "Email not set in settings.json, skipping SSH key setup"
119 | return 1
120 | fi
121 |
122 | local ssh_dir="$HOME/.ssh"
123 | local ssh_key="$ssh_dir/id_rsa"
124 |
125 | # Create SSH directory if it doesn't exist
126 | if [[ ! -d "$ssh_dir" ]]; then
127 | mkdir -p "$ssh_dir"
128 | chmod 700 "$ssh_dir"
129 | fi
130 |
131 | # Generate SSH key if it doesn't exist
132 | if [[ ! -f "$ssh_key" ]]; then
133 | log_info "Generating SSH key for $email"
134 | ssh-keygen -t rsa -b 4096 -C "$email" -f "$ssh_key" -N ""
135 | chmod 600 "$ssh_key"
136 | chmod 644 "$ssh_key.pub"
137 |
138 | log_success "SSH key generated successfully"
139 | log_info "Public key location: $ssh_key.pub"
140 |
141 | # Start SSH agent and add key
142 | eval "$(ssh-agent -s)"
143 | ssh-add "$ssh_key"
144 |
145 | # Display public key
146 | echo
147 | log_info "Your SSH public key (copy this to GitHub/GitLab):"
148 | echo "=========================================="
149 | cat "$ssh_key.pub"
150 | echo "=========================================="
151 | echo
152 | else
153 | log_info "SSH key already exists at $ssh_key"
154 | fi
155 | }
156 |
157 | create_gitignore_global() {
158 | log_step "Creating global gitignore"
159 |
160 | local gitignore_global="$HOME/.gitignore_global"
161 |
162 | cat > "$gitignore_global" << 'EOF'
163 | # OS generated files
164 | .DS_Store
165 | .DS_Store?
166 | ._*
167 | .Spotlight-V100
168 | .Trashes
169 | ehthumbs.db
170 | Thumbs.db
171 |
172 | # Editor files
173 | *~
174 | *.swp
175 | *.swo
176 | .vscode/
177 | .idea/
178 | *.sublime-project
179 | *.sublime-workspace
180 |
181 | # Logs
182 | *.log
183 | npm-debug.log*
184 | yarn-debug.log*
185 | yarn-error.log*
186 |
187 | # Runtime data
188 | pids
189 | *.pid
190 | *.seed
191 | *.pid.lock
192 |
193 | # Dependency directories
194 | node_modules/
195 | bower_components/
196 |
197 | # Optional npm cache directory
198 | .npm
199 |
200 | # Optional REPL history
201 | .node_repl_history
202 |
203 | # Output of 'npm pack'
204 | *.tgz
205 |
206 | # Yarn Integrity file
207 | .yarn-integrity
208 |
209 | # dotenv environment variables file
210 | .env
211 |
212 | # Temporary folders
213 | tmp/
214 | temp/
215 | .tmp/
216 |
217 | # Build outputs
218 | dist/
219 | build/
220 | out/
221 |
222 | # IDE files
223 | .vscode/
224 | .idea/
225 | *.iml
226 | *.ipr
227 | *.iws
228 |
229 | # Python
230 | __pycache__/
231 | *.py[cod]
232 | *$py.class
233 | *.so
234 | .Python
235 | env/
236 | venv/
237 | ENV/
238 | env.bak/
239 | venv.bak/
240 | .pytest_cache/
241 |
242 | # Virtual environments
243 | .virtualenv
244 |
245 | # Jupyter Notebook
246 | .ipynb_checkpoints
247 |
248 | # pyenv
249 | .python-version
250 |
251 | # Rust
252 | target/
253 | Cargo.lock
254 |
255 | # Go
256 | vendor/
257 |
258 | # Java
259 | *.class
260 | *.jar
261 | *.war
262 | *.ear
263 |
264 | # C/C++
265 | *.o
266 | *.so
267 | *.dylib
268 | *.exe
269 |
270 | # Archives
271 | *.zip
272 | *.tar.gz
273 | *.rar
274 | *.7z
275 | EOF
276 |
277 | git config --global core.excludesfile "$gitignore_global"
278 |
279 | log_success "Global gitignore created at $gitignore_global"
280 | }
281 |
282 | main() {
283 | log_info "Starting Git setup"
284 |
285 | # Check if Git is already installed
286 | if command -v git >/dev/null 2>&1; then
287 | log_info "Git is already installed"
288 | else
289 | install_git
290 | fi
291 |
292 | configure_git
293 | create_gitignore_global
294 | setup_ssh_key
295 |
296 | log_success "Git setup completed successfully"
297 |
298 | # Show Git version
299 | local git_version
300 | git_version=$(git --version)
301 | log_info "Installed: $git_version"
302 | }
303 |
304 | # Run main function if script is executed directly
305 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
306 | main "$@"
307 | fi
--------------------------------------------------------------------------------
/programs/github-desktop.ps1:
--------------------------------------------------------------------------------
1 | cinst -y github-desktop
--------------------------------------------------------------------------------
/programs/golang.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # GO PROGRAMMING LANGUAGE INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Go programming language with development environment
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_golang() {
19 | log_step "Installing Go programming language"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Get Go version from version.json
25 | local go_version
26 | go_version=$(get_json_value "$PROJECT_ROOT/bootstrap/version.json" ".golang")
27 |
28 | if [[ "$go_version" == "null" ]]; then
29 | log_warning "Go version not found in version.json, using 1.21"
30 | go_version="1.21"
31 | fi
32 |
33 | log_info "Installing Go v${go_version}"
34 |
35 | # Check if purge mode is enabled
36 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
37 | log_step "Purging existing Go installation"
38 | sudo rm -rf /usr/local/go 2>/dev/null || true
39 | rm -rf "$HOME/go" 2>/dev/null || true
40 |
41 | # Remove Go paths from shell profiles
42 | sed -i '/GOROOT/d' "$HOME/.bashrc" 2>/dev/null || true
43 | sed -i '/GOPATH/d' "$HOME/.bashrc" 2>/dev/null || true
44 | sed -i '/go\/bin/d' "$HOME/.bashrc" 2>/dev/null || true
45 | fi
46 |
47 | # Try package manager first
48 | case "$pm" in
49 | "apt")
50 | # Check if we can install Go from package manager
51 | if install_go_from_package; then
52 | return 0
53 | else
54 | install_go_from_binary "$go_version"
55 | fi
56 | ;;
57 | "pacman")
58 | sudo pacman -S --noconfirm go 2>/dev/null || install_go_from_binary "$go_version"
59 | ;;
60 | "yay")
61 | yay -S --noconfirm go 2>/dev/null || install_go_from_binary "$go_version"
62 | ;;
63 | "dnf")
64 | sudo dnf install -y golang 2>/dev/null || install_go_from_binary "$go_version"
65 | ;;
66 | "zypper")
67 | sudo zypper install -y go 2>/dev/null || install_go_from_binary "$go_version"
68 | ;;
69 | "snap")
70 | sudo snap install go --classic
71 | ;;
72 | "brew")
73 | brew install go
74 | ;;
75 | *)
76 | install_go_from_binary "$go_version"
77 | ;;
78 | esac
79 |
80 | log_success "Go installed successfully"
81 | }
82 |
83 | install_go_from_package() {
84 | log_step "Attempting to install Go from package manager"
85 |
86 | sudo apt update
87 | if sudo apt install -y golang-go; then
88 | log_success "Go installed from package manager"
89 | return 0
90 | else
91 | log_info "Package manager installation failed, falling back to binary"
92 | return 1
93 | fi
94 | }
95 |
96 | install_go_from_binary() {
97 | local go_version="$1"
98 |
99 | log_step "Installing Go from binary release"
100 |
101 | local architecture
102 | local os_type
103 |
104 | architecture=$(uname -m)
105 | os_type=$(uname -s | tr '[:upper:]' '[:lower:]')
106 |
107 | # Map architecture names
108 | case "$architecture" in
109 | "x86_64")
110 | architecture="amd64"
111 | ;;
112 | "i386"|"i686")
113 | architecture="386"
114 | ;;
115 | "aarch64"|"arm64")
116 | architecture="arm64"
117 | ;;
118 | "armv6l")
119 | architecture="armv6l"
120 | ;;
121 | *)
122 | log_error "Unsupported architecture: $architecture"
123 | return 1
124 | ;;
125 | esac
126 |
127 | local download_url="https://golang.org/dl/go${go_version}.${os_type}-${architecture}.tar.gz"
128 | local temp_file="/tmp/go${go_version}.${os_type}-${architecture}.tar.gz"
129 |
130 | log_info "Downloading Go ${go_version} for ${os_type}-${architecture}"
131 |
132 | # Download Go binary
133 | if curl -L "$download_url" -o "$temp_file"; then
134 | # Remove existing installation
135 | sudo rm -rf /usr/local/go
136 |
137 | # Extract to /usr/local
138 | sudo tar -C /usr/local -xzf "$temp_file"
139 |
140 | # Clean up
141 | rm -f "$temp_file"
142 |
143 | log_success "Go binary installed to /usr/local/go"
144 | else
145 | log_error "Failed to download Go binary"
146 | return 1
147 | fi
148 | }
149 |
150 | configure_golang() {
151 | log_step "Configuring Go environment"
152 |
153 | # Create Go workspace directories
154 | local gopath="$HOME/go"
155 | local gobin="$gopath/bin"
156 |
157 | mkdir -p "$gopath"/{src,pkg,bin}
158 | log_info "Created Go workspace at $gopath"
159 |
160 | # Configure environment variables
161 | local bashrc="$HOME/.bashrc"
162 | local go_config="# Go configuration added by matbrgz dotfiles"
163 |
164 | # Check if Go config already exists
165 | if ! grep -q "$go_config" "$bashrc" 2>/dev/null; then
166 | cat >> "$bashrc" << EOF
167 |
168 | # Go configuration added by matbrgz dotfiles
169 | export GOROOT=/usr/local/go
170 | export GOPATH=$gopath
171 | export GOBIN=$gobin
172 | export PATH=\$PATH:\$GOROOT/bin:\$GOBIN
173 |
174 | # Go aliases
175 | alias go-version='go version'
176 | alias go-env='go env'
177 | alias go-install='go install'
178 | alias go-build='go build'
179 | alias go-run='go run'
180 | alias go-test='go test'
181 | alias go-fmt='go fmt'
182 | alias go-vet='go vet'
183 | alias go-mod-init='go mod init'
184 | alias go-mod-tidy='go mod tidy'
185 | alias go-mod-download='go mod download'
186 | alias go-get='go get'
187 | alias go-clean='go clean'
188 | alias go-workspace='cd \$GOPATH'
189 | EOF
190 |
191 | log_success "Go configuration added to $bashrc"
192 | else
193 | log_info "Go configuration already exists in $bashrc"
194 | fi
195 |
196 | # Export for current session
197 | export GOROOT=/usr/local/go
198 | export GOPATH="$gopath"
199 | export GOBIN="$gobin"
200 | export PATH="$PATH:$GOROOT/bin:$GOBIN"
201 | }
202 |
203 | install_go_tools() {
204 | log_step "Installing Go development tools"
205 |
206 | # Ensure Go is in PATH for current session
207 | export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin"
208 |
209 | if ! command -v go >/dev/null 2>&1; then
210 | log_error "Go command not available"
211 | return 1
212 | fi
213 |
214 | local go_tools=(
215 | "golang.org/x/tools/cmd/goimports@latest"
216 | "golang.org/x/tools/cmd/godoc@latest"
217 | "golang.org/x/tools/cmd/gofmt@latest"
218 | "golang.org/x/lint/golint@latest"
219 | "honnef.co/go/tools/cmd/staticcheck@latest"
220 | "github.com/gorilla/mux@latest"
221 | "github.com/gin-gonic/gin@latest"
222 | "github.com/go-delve/delve/cmd/dlv@latest"
223 | "github.com/cosmtrek/air@latest"
224 | "github.com/swaggo/swag/cmd/swag@latest"
225 | )
226 |
227 | for tool in "${go_tools[@]}"; do
228 | log_info "Installing $tool"
229 | go install "$tool" 2>/dev/null || log_warning "Failed to install $tool"
230 | done
231 |
232 | log_success "Go development tools installed"
233 | }
234 |
235 | create_sample_project() {
236 | log_step "Creating sample Go project"
237 |
238 | local sample_dir="$HOME/go/src/hello"
239 |
240 | if [[ ! -d "$sample_dir" ]]; then
241 | mkdir -p "$sample_dir"
242 |
243 | cat > "$sample_dir/main.go" << 'EOF'
244 | package main
245 |
246 | import (
247 | "fmt"
248 | "net/http"
249 | )
250 |
251 | func main() {
252 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
253 | fmt.Fprintf(w, "Hello, Go! 🚀\n")
254 | fmt.Fprintf(w, "Request URL: %s\n", r.URL.Path)
255 | fmt.Fprintf(w, "Method: %s\n", r.Method)
256 | })
257 |
258 | fmt.Println("Starting server on :8080")
259 | fmt.Println("Visit: http://localhost:8080")
260 |
261 | if err := http.ListenAndServe(":8080", nil); err != nil {
262 | fmt.Printf("Server error: %v\n", err)
263 | }
264 | }
265 | EOF
266 |
267 | cat > "$sample_dir/go.mod" << 'EOF'
268 | module hello
269 |
270 | go 1.21
271 | EOF
272 |
273 | log_success "Sample project created at $sample_dir"
274 | else
275 | log_info "Sample project already exists"
276 | fi
277 | }
278 |
279 | verify_installation() {
280 | log_step "Verifying Go installation"
281 |
282 | # Add Go to PATH for verification
283 | export PATH="$PATH:/usr/local/go/bin"
284 |
285 | if command -v go >/dev/null 2>&1; then
286 | local go_version
287 | go_version=$(go version)
288 | log_success "Go version: $go_version"
289 |
290 | # Check Go environment
291 | local goroot gopath
292 | goroot=$(go env GOROOT 2>/dev/null || echo "not set")
293 | gopath=$(go env GOPATH 2>/dev/null || echo "not set")
294 |
295 | log_info "GOROOT: $goroot"
296 | log_info "GOPATH: $gopath"
297 |
298 | # Test compilation
299 | if echo 'package main; import "fmt"; func main() { fmt.Println("Hello, Go!") }' | go run -; then
300 | log_success "Go compilation test passed"
301 | else
302 | log_warning "Go compilation test failed"
303 | fi
304 |
305 | else
306 | log_error "Go command not found"
307 | log_info "Try restarting your shell or run: source ~/.bashrc"
308 | return 1
309 | fi
310 | }
311 |
312 | show_usage() {
313 | echo
314 | log_info "Go usage:"
315 | echo " - Check version: go-version"
316 | echo " - Initialize module: go-mod-init myproject"
317 | echo " - Run program: go-run main.go"
318 | echo " - Build binary: go-build"
319 | echo " - Install package: go-get github.com/user/package"
320 | echo " - Format code: go-fmt ./..."
321 | echo " - Run tests: go-test ./..."
322 | echo " - Go to workspace: go-workspace"
323 | echo
324 | log_info "Sample project:"
325 | echo " - Location: $HOME/go/src/hello"
326 | echo " - Run: cd $HOME/go/src/hello && go run main.go"
327 | echo " - Visit: http://localhost:8080"
328 | echo
329 | log_info "Development tools installed:"
330 | echo " - goimports, godoc, golint, staticcheck"
331 | echo " - delve debugger (dlv), air (live reload)"
332 | echo " - Popular frameworks: gin, mux"
333 | }
334 |
335 | main() {
336 | log_info "Starting Go programming language setup"
337 |
338 | install_golang
339 | configure_golang
340 | install_go_tools
341 | create_sample_project
342 | verify_installation
343 | show_usage
344 |
345 | log_success "Go setup completed successfully"
346 | log_info "Restart your shell or run 'source ~/.bashrc' to use Go"
347 | }
348 |
349 | # Run main function if script is executed directly
350 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
351 | main "$@"
352 | fi
353 |
--------------------------------------------------------------------------------
/programs/google-backup-and-sync.ps1:
--------------------------------------------------------------------------------
1 | cinst -y google-backup-and-sync
--------------------------------------------------------------------------------
/programs/herokutoolbelt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | export PATH="${PATH}:/usr/local/heroku/bin"
9 |
--------------------------------------------------------------------------------
/programs/httrack.ps1:
--------------------------------------------------------------------------------
1 | cinst -y httrack
--------------------------------------------------------------------------------
/programs/hyperv.ps1:
--------------------------------------------------------------------------------
1 | #Enable HyperV
2 | cinst -y Microsoft-Hyper-V-All --source="'windowsFeatures'"
--------------------------------------------------------------------------------
/programs/insomnia.ps1:
--------------------------------------------------------------------------------
1 | cinst -y insomnia-rest-api-client
--------------------------------------------------------------------------------
/programs/jdk.ps1:
--------------------------------------------------------------------------------
1 | cinst -y jdk8
--------------------------------------------------------------------------------
/programs/kubectl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # KUBECTL INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install kubectl for Kubernetes cluster management
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_kubectl() {
19 | log_step "Installing kubectl"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Get kubectl version from version.json
25 | local kubectl_version
26 | kubectl_version=$(get_json_value "$PROJECT_ROOT/bootstrap/version.json" ".kubectl")
27 |
28 | if [[ "$kubectl_version" == "null" ]]; then
29 | log_warning "kubectl version not found in version.json, using latest"
30 | kubectl_version="latest"
31 | fi
32 |
33 | log_info "Installing kubectl v${kubectl_version}"
34 |
35 | # Check if purge mode is enabled
36 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
37 | log_step "Purging existing kubectl installation"
38 | sudo rm -f /usr/local/bin/kubectl /usr/bin/kubectl 2>/dev/null || true
39 |
40 | case "$pm" in
41 | "apt")
42 | sudo apt remove -y kubectl 2>/dev/null || true
43 | sudo apt autoremove -y
44 | ;;
45 | "pacman"|"yay")
46 | sudo pacman -Rs --noconfirm kubectl 2>/dev/null || true
47 | ;;
48 | "dnf")
49 | sudo dnf remove -y kubectl 2>/dev/null || true
50 | ;;
51 | esac
52 | fi
53 |
54 | # Try package manager first, then fallback to binary installation
55 | case "$pm" in
56 | "apt")
57 | if install_kubectl_apt; then
58 | return 0
59 | else
60 | install_kubectl_binary "$kubectl_version"
61 | fi
62 | ;;
63 | "pacman")
64 | sudo pacman -S --noconfirm kubectl 2>/dev/null || install_kubectl_binary "$kubectl_version"
65 | ;;
66 | "yay")
67 | yay -S --noconfirm kubectl 2>/dev/null || install_kubectl_binary "$kubectl_version"
68 | ;;
69 | "dnf")
70 | sudo dnf install -y kubectl 2>/dev/null || install_kubectl_binary "$kubectl_version"
71 | ;;
72 | "zypper")
73 | sudo zypper install -y kubectl 2>/dev/null || install_kubectl_binary "$kubectl_version"
74 | ;;
75 | "snap")
76 | sudo snap install kubectl --classic
77 | ;;
78 | "brew")
79 | brew install kubectl
80 | ;;
81 | *)
82 | install_kubectl_binary "$kubectl_version"
83 | ;;
84 | esac
85 |
86 | log_success "kubectl installed successfully"
87 | }
88 |
89 | install_kubectl_apt() {
90 | log_step "Installing kubectl via APT"
91 |
92 | # Add Kubernetes repository
93 | sudo apt update
94 | sudo apt install -y apt-transport-https ca-certificates curl gnupg
95 |
96 | # Add Kubernetes signing key
97 | if curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg; then
98 | # Add repository
99 | echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
100 |
101 | sudo apt update
102 | sudo apt install -y kubectl
103 |
104 | log_success "kubectl installed via APT"
105 | return 0
106 | else
107 | log_warning "Failed to add Kubernetes repository, falling back to binary installation"
108 | return 1
109 | fi
110 | }
111 |
112 | install_kubectl_binary() {
113 | local kubectl_version="$1"
114 |
115 | log_step "Installing kubectl from binary release"
116 |
117 | local architecture
118 | local os_type
119 |
120 | architecture=$(uname -m)
121 | os_type=$(uname -s | tr '[:upper:]' '[:lower:]')
122 |
123 | # Map architecture names
124 | case "$architecture" in
125 | "x86_64")
126 | architecture="amd64"
127 | ;;
128 | "aarch64"|"arm64")
129 | architecture="arm64"
130 | ;;
131 | "armv7l")
132 | architecture="arm"
133 | ;;
134 | *)
135 | log_error "Unsupported architecture: $architecture"
136 | return 1
137 | ;;
138 | esac
139 |
140 | # Get download URL
141 | local download_url
142 | if [[ "$kubectl_version" == "latest" ]]; then
143 | # Get latest stable version
144 | kubectl_version=$(curl -L -s https://dl.k8s.io/release/stable.txt)
145 | download_url="https://dl.k8s.io/release/${kubectl_version}/bin/${os_type}/${architecture}/kubectl"
146 | else
147 | download_url="https://dl.k8s.io/release/v${kubectl_version}/bin/${os_type}/${architecture}/kubectl"
148 | fi
149 |
150 | log_info "Downloading kubectl ${kubectl_version} for ${os_type}-${architecture}"
151 |
152 | # Download and install
153 | if curl -L "$download_url" -o /tmp/kubectl; then
154 | sudo mv /tmp/kubectl /usr/local/bin/kubectl
155 | sudo chmod +x /usr/local/bin/kubectl
156 |
157 | # Create symlink for convenience
158 | sudo ln -sf /usr/local/bin/kubectl /usr/bin/kubectl 2>/dev/null || true
159 |
160 | log_success "kubectl binary installed to /usr/local/bin/kubectl"
161 | else
162 | log_error "Failed to download kubectl binary"
163 | return 1
164 | fi
165 | }
166 |
167 | configure_kubectl() {
168 | log_step "Configuring kubectl"
169 |
170 | # Create kubectl config directory
171 | local kube_dir="$HOME/.kube"
172 | mkdir -p "$kube_dir"
173 | chmod 700 "$kube_dir"
174 |
175 | # Create basic config file if it doesn't exist
176 | local kube_config="$kube_dir/config"
177 | if [[ ! -f "$kube_config" ]]; then
178 | cat > "$kube_config" << 'EOF'
179 | apiVersion: v1
180 | kind: Config
181 | clusters: []
182 | contexts: []
183 | current-context: ""
184 | preferences: {}
185 | users: []
186 | EOF
187 |
188 | chmod 600 "$kube_config"
189 | log_success "kubectl config file created at $kube_config"
190 | else
191 | log_info "kubectl config file already exists"
192 | fi
193 | }
194 |
195 | setup_bash_completion() {
196 | log_step "Setting up bash completion for kubectl"
197 |
198 | local completion_dir="/etc/bash_completion.d"
199 | local completion_file="$completion_dir/kubectl"
200 |
201 | if [[ -d "$completion_dir" ]]; then
202 | # Generate kubectl completion
203 | if command -v kubectl >/dev/null 2>&1; then
204 | kubectl completion bash | sudo tee "$completion_file" > /dev/null
205 | log_success "kubectl bash completion configured"
206 | else
207 | log_warning "kubectl not available for completion generation"
208 | fi
209 | else
210 | log_warning "Bash completion directory not found, skipping"
211 | fi
212 |
213 | # Add completion to user's bashrc
214 | local bashrc="$HOME/.bashrc"
215 | local completion_section="# kubectl completion added by matbrgz dotfiles"
216 |
217 | if ! grep -q "$completion_section" "$bashrc" 2>/dev/null; then
218 | cat >> "$bashrc" << 'EOF'
219 |
220 | # kubectl completion added by matbrgz dotfiles
221 | if command -v kubectl >/dev/null 2>&1; then
222 | source <(kubectl completion bash)
223 | complete -F __start_kubectl k
224 | fi
225 | EOF
226 |
227 | log_success "kubectl completion added to $bashrc"
228 | fi
229 | }
230 |
231 | create_kubectl_aliases() {
232 | log_step "Creating kubectl aliases"
233 |
234 | local bashrc="$HOME/.bashrc"
235 | local aliases_section="# kubectl aliases added by matbrgz dotfiles"
236 |
237 | # Check if aliases already exist
238 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
239 | log_info "kubectl aliases already exist in $bashrc"
240 | return 0
241 | fi
242 |
243 | # Add kubectl aliases
244 | cat >> "$bashrc" << 'EOF'
245 |
246 | # kubectl aliases added by matbrgz dotfiles
247 | alias k='kubectl'
248 | alias kgp='kubectl get pods'
249 | alias kgs='kubectl get services'
250 | alias kgd='kubectl get deployments'
251 | alias kgn='kubectl get nodes'
252 | alias kga='kubectl get all'
253 | alias kdp='kubectl describe pod'
254 | alias kds='kubectl describe service'
255 | alias kdd='kubectl describe deployment'
256 | alias kdn='kubectl describe node'
257 | alias kaf='kubectl apply -f'
258 | alias kdf='kubectl delete -f'
259 | alias kex='kubectl exec -it'
260 | alias klogs='kubectl logs'
261 | alias klogsf='kubectl logs -f'
262 | alias kctx='kubectl config current-context'
263 | alias kctxs='kubectl config get-contexts'
264 | alias kctxu='kubectl config use-context'
265 | alias kns='kubectl config set-context --current --namespace'
266 |
267 | # kubectl helpers
268 | alias k-pods='kubectl get pods --all-namespaces'
269 | alias k-nodes='kubectl get nodes -o wide'
270 | alias k-top-pods='kubectl top pods'
271 | alias k-top-nodes='kubectl top nodes'
272 | alias k-watch-pods='kubectl get pods -w'
273 | alias k-port-forward='kubectl port-forward'
274 | EOF
275 |
276 | log_success "kubectl aliases added to $bashrc"
277 | }
278 |
279 | install_additional_tools() {
280 | log_step "Installing additional Kubernetes tools"
281 |
282 | # Install kubectx and kubens for easier context/namespace switching
283 | local tools_dir="/usr/local/bin"
284 |
285 | # kubectx
286 | if ! command -v kubectx >/dev/null 2>&1; then
287 | log_info "Installing kubectx"
288 | if curl -L https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx -o /tmp/kubectx; then
289 | sudo mv /tmp/kubectx "$tools_dir/kubectx"
290 | sudo chmod +x "$tools_dir/kubectx"
291 | log_success "kubectx installed"
292 | else
293 | log_warning "Failed to install kubectx"
294 | fi
295 | fi
296 |
297 | # kubens
298 | if ! command -v kubens >/dev/null 2>&1; then
299 | log_info "Installing kubens"
300 | if curl -L https://raw.githubusercontent.com/ahmetb/kubectx/master/kubens -o /tmp/kubens; then
301 | sudo mv /tmp/kubens "$tools_dir/kubens"
302 | sudo chmod +x "$tools_dir/kubens"
303 | log_success "kubens installed"
304 | else
305 | log_warning "Failed to install kubens"
306 | fi
307 | fi
308 | }
309 |
310 | verify_installation() {
311 | log_step "Verifying kubectl installation"
312 |
313 | if command -v kubectl >/dev/null 2>&1; then
314 | local version
315 | version=$(kubectl version --client --short 2>/dev/null || kubectl version --client 2>/dev/null | head -1)
316 | log_success "kubectl version: $version"
317 |
318 | # Check if kubectl can connect to a cluster
319 | if kubectl cluster-info >/dev/null 2>&1; then
320 | log_success "kubectl can connect to a Kubernetes cluster"
321 | else
322 | log_info "kubectl installed but no cluster configured"
323 | log_info "Use 'kubectl config' commands to configure cluster access"
324 | fi
325 |
326 | # Check additional tools
327 | if command -v kubectx >/dev/null 2>&1; then
328 | log_success "kubectx is available"
329 | fi
330 |
331 | if command -v kubens >/dev/null 2>&1; then
332 | log_success "kubens is available"
333 | fi
334 |
335 | else
336 | log_error "kubectl command not found"
337 | return 1
338 | fi
339 | }
340 |
341 | show_usage() {
342 | echo
343 | log_info "kubectl usage:"
344 | echo " - Get pods: kgp or kubectl get pods"
345 | echo " - Get all resources: kga"
346 | echo " - Apply config: kaf file.yaml"
347 | echo " - Execute in pod: kex pod-name -- /bin/bash"
348 | echo " - View logs: klogs pod-name"
349 | echo " - Port forward: k-port-forward pod-name 8080:80"
350 | echo
351 | log_info "Context management:"
352 | echo " - Current context: kctx"
353 | echo " - List contexts: kctxs"
354 | echo " - Switch context: kctxu context-name"
355 | echo " - Switch namespace: kns namespace-name"
356 | echo
357 | log_info "Additional tools:"
358 | echo " - kubectx: Switch between clusters"
359 | echo " - kubens: Switch between namespaces"
360 | echo
361 | log_info "Configuration:"
362 | echo " - Config file: $HOME/.kube/config"
363 | echo " - Add cluster: kubectl config set-cluster"
364 | echo " - Add user: kubectl config set-credentials"
365 | echo " - Add context: kubectl config set-context"
366 | }
367 |
368 | main() {
369 | log_info "Starting kubectl setup"
370 |
371 | install_kubectl
372 | configure_kubectl
373 | setup_bash_completion
374 | create_kubectl_aliases
375 | install_additional_tools
376 | verify_installation
377 | show_usage
378 |
379 | log_success "kubectl setup completed successfully"
380 | log_info "Use 'source ~/.bashrc' to load new aliases and completion"
381 | }
382 |
383 | # Run main function if script is executed directly
384 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
385 | main "$@"
386 | fi
387 |
--------------------------------------------------------------------------------
/programs/kubernetes-helm.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | HEADER_TYPE="$(uname -s)"
9 | ARCHITECTURE_TYPE="$(uname -m)"
10 | KUBERNETES_HELM_VERSION="$(jq -r '.KUBERNETES_HELM_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
11 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
12 | echo "Kubernetes Helm purge not implemented yet! Skipping."
13 | fi
14 | if ! curl -L https://storage.googleapis.com/kubernetes-helm/helm-v"${KUBERNETES_HELM_VERSION}"-"${HEADER_TYPE}"-"${ARCHITECTURE_TYPE}".tar.gz; then
15 | echo "Kubernetes Helm Download failed! Exiting."
16 | kill $$
17 | fi
18 | if [ -d /usr/local/bin/helm ]; then
19 | sudo rm -f -R /usr/local/bin/helm
20 | fi
21 | mkdir -p /usr/local/bin/helm
22 | chmod 777 /usr/local/bin/helm
23 | tar -zxvf helm-v"${KUBERNETES_HELM_VERSION}"-"${HEADER_TYPE}"-"${ARCHITECTURE_TYPE}".tar.gz
24 | sudo mv "${HEADER_TYPE}"-"${ARCHITECTURE_TYPE}"/helm /usr/local/bin/helm
25 |
--------------------------------------------------------------------------------
/programs/megasync.ps1:
--------------------------------------------------------------------------------
1 | cinst -y megasync
--------------------------------------------------------------------------------
/programs/mosh.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # MOSH INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Mosh (mobile shell) for better SSH connections
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_mosh() {
19 | log_step "Installing Mosh"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing Mosh installation"
27 | case "$pm" in
28 | "apt")
29 | sudo apt remove -y mosh 2>/dev/null || true
30 | sudo apt autoremove -y
31 | ;;
32 | "pacman"|"yay")
33 | sudo pacman -Rs --noconfirm mosh 2>/dev/null || true
34 | ;;
35 | "dnf")
36 | sudo dnf remove -y mosh 2>/dev/null || true
37 | ;;
38 | *)
39 | log_warning "Purge not implemented for package manager: $pm"
40 | ;;
41 | esac
42 | fi
43 |
44 | # Install dependencies first
45 | install_dependencies
46 |
47 | # Install Mosh
48 | case "$pm" in
49 | "apt")
50 | sudo apt update
51 | sudo apt install -y mosh
52 | ;;
53 | "pacman")
54 | sudo pacman -S --noconfirm mosh
55 | ;;
56 | "yay")
57 | yay -S --noconfirm mosh
58 | ;;
59 | "dnf")
60 | sudo dnf install -y mosh
61 | ;;
62 | "zypper")
63 | sudo zypper install -y mosh
64 | ;;
65 | "snap")
66 | sudo snap install mosh --classic
67 | ;;
68 | "brew")
69 | brew install mosh
70 | ;;
71 | *)
72 | install_mosh_from_source
73 | ;;
74 | esac
75 |
76 | log_success "Mosh installed successfully"
77 | }
78 |
79 | install_dependencies() {
80 | log_step "Installing Mosh dependencies"
81 |
82 | local pm
83 | pm=$(detect_package_manager)
84 |
85 | case "$pm" in
86 | "apt")
87 | sudo apt install -y \
88 | build-essential \
89 | pkg-config \
90 | libprotobuf-dev \
91 | protobuf-compiler \
92 | libncurses5-dev \
93 | zlib1g-dev \
94 | libssl-dev \
95 | perl
96 | ;;
97 | "pacman")
98 | sudo pacman -S --noconfirm \
99 | base-devel \
100 | protobuf \
101 | ncurses \
102 | zlib \
103 | openssl \
104 | perl
105 | ;;
106 | "dnf")
107 | sudo dnf install -y \
108 | gcc-c++ \
109 | pkg-config \
110 | protobuf-devel \
111 | protobuf-compiler \
112 | ncurses-devel \
113 | zlib-devel \
114 | openssl-devel \
115 | perl
116 | ;;
117 | *)
118 | log_info "Dependency installation not configured for $pm"
119 | ;;
120 | esac
121 | }
122 |
123 | install_mosh_from_source() {
124 | log_step "Installing Mosh from source"
125 |
126 | local mosh_version="1.4.0"
127 | local download_url="https://github.com/mobile-shell/mosh/releases/download/mosh-${mosh_version}/mosh-${mosh_version}.tar.gz"
128 | local temp_dir="/tmp/mosh-build"
129 |
130 | # Create temp directory
131 | mkdir -p "$temp_dir"
132 | cd "$temp_dir"
133 |
134 | # Download and extract
135 | if curl -L "$download_url" -o "mosh-${mosh_version}.tar.gz"; then
136 | tar -xzf "mosh-${mosh_version}.tar.gz"
137 | cd "mosh-${mosh_version}"
138 |
139 | # Configure, compile and install
140 | ./configure --prefix=/usr/local
141 | make -j$(nproc)
142 | sudo make install
143 |
144 | # Update library cache
145 | sudo ldconfig 2>/dev/null || true
146 |
147 | log_success "Mosh compiled and installed from source"
148 | else
149 | log_error "Failed to download Mosh source"
150 | return 1
151 | fi
152 |
153 | # Cleanup
154 | rm -rf "$temp_dir"
155 | }
156 |
157 | configure_firewall() {
158 | log_step "Configuring firewall for Mosh"
159 |
160 | # Mosh uses UDP ports 60000-61000
161 | if command -v ufw >/dev/null 2>&1; then
162 | log_step "Configuring UFW firewall"
163 | sudo ufw allow 60000:61000/udp comment "Mosh" 2>/dev/null || true
164 | log_success "UFW rules added for Mosh"
165 | elif command -v firewall-cmd >/dev/null 2>&1; then
166 | log_step "Configuring firewalld"
167 | sudo firewall-cmd --permanent --add-port=60000-61000/udp 2>/dev/null || true
168 | sudo firewall-cmd --reload 2>/dev/null || true
169 | log_success "firewalld rules added for Mosh"
170 | else
171 | log_warning "No supported firewall found"
172 | log_info "Manually open UDP ports 60000-61000 if using a firewall"
173 | fi
174 | }
175 |
176 | create_mosh_aliases() {
177 | log_step "Creating Mosh aliases"
178 |
179 | local bashrc="$HOME/.bashrc"
180 | local aliases_section="# Mosh aliases added by matbrgz dotfiles"
181 |
182 | # Check if aliases already exist
183 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
184 | log_info "Mosh aliases already exist in $bashrc"
185 | return 0
186 | fi
187 |
188 | # Add Mosh aliases
189 | cat >> "$bashrc" << 'EOF'
190 |
191 | # Mosh aliases added by matbrgz dotfiles
192 | alias mosh-server='mosh-server new -s'
193 | alias mosh-local='mosh localhost'
194 | EOF
195 |
196 | log_success "Mosh aliases added to $bashrc"
197 | }
198 |
199 | verify_installation() {
200 | log_step "Verifying Mosh installation"
201 |
202 | if command -v mosh >/dev/null 2>&1; then
203 | local version
204 | version=$(mosh --version 2>&1 | head -n1)
205 | log_success "Mosh version: $version"
206 | else
207 | log_error "Mosh command not found"
208 | return 1
209 | fi
210 |
211 | if command -v mosh-server >/dev/null 2>&1; then
212 | log_success "mosh-server is available"
213 | else
214 | log_warning "mosh-server not found"
215 | fi
216 |
217 | if command -v mosh-client >/dev/null 2>&1; then
218 | log_success "mosh-client is available"
219 | else
220 | log_warning "mosh-client not found"
221 | fi
222 | }
223 |
224 | show_usage() {
225 | echo
226 | log_info "Mosh usage:"
227 | echo " - Connect to server: mosh user@hostname"
228 | echo " - Connect with SSH port: mosh --ssh='ssh -p 2222' user@hostname"
229 | echo " - Local connection: mosh-local"
230 | echo " - Manual server start: mosh-server"
231 | echo
232 | log_info "Mosh advantages:"
233 | echo " - Survives network disconnections"
234 | echo " - Roaming between networks"
235 | echo " - Local echo for low-latency typing"
236 | echo " - Intelligent local editing"
237 | echo
238 | log_warning "Note: Mosh requires UDP ports 60000-61000 to be open"
239 | }
240 |
241 | main() {
242 | log_info "Starting Mosh setup"
243 |
244 | install_mosh
245 | configure_firewall
246 | create_mosh_aliases
247 | verify_installation
248 | show_usage
249 |
250 | log_success "Mosh setup completed successfully"
251 | log_info "Use 'source ~/.bashrc' to load new aliases"
252 | }
253 |
254 | # Run main function if script is executed directly
255 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
256 | main "$@"
257 | fi
258 |
--------------------------------------------------------------------------------
/programs/mysql-phpmyadmin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
9 | sudo apt -y purge phpmyadmin
10 | fi
11 | sudo /etc/init.d/mysql stop
12 | sudo apt -y install phpmyadmin
13 | sudo /etc/init.d/mysql start
14 | dpkg --get-selections | grep phpmyadmin
15 | defaultfolder="$(jq -r ".personal.defaultfolder" "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
16 | echo '' >>"${defaultfolder}"/phpmyadmin
17 |
--------------------------------------------------------------------------------
/programs/mysql.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # MYSQL SERVER INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure MySQL database server
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_mysql() {
19 | log_step "Installing MySQL Server"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Get MySQL version from version.json
25 | local mysql_version
26 | mysql_version=$(get_json_value "$PROJECT_ROOT/bootstrap/version.json" ".mysql")
27 |
28 | if [[ "$mysql_version" == "null" ]]; then
29 | log_warning "MySQL version not found in version.json, using 8.0"
30 | mysql_version="8.0"
31 | fi
32 |
33 | # Extract major.minor version (e.g., "9.1.0" -> "8.0")
34 | local mysql_major_minor
35 | mysql_major_minor=$(echo "$mysql_version" | cut -d'.' -f1-2)
36 |
37 | log_info "Installing MySQL $mysql_major_minor"
38 |
39 | # Check if purge mode is enabled
40 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
41 | log_step "Purging existing MySQL installation"
42 | case "$pm" in
43 | "apt")
44 | sudo systemctl stop mysql 2>/dev/null || true
45 | sudo apt remove -y mysql-server mysql-client mysql-common 2>/dev/null || true
46 | sudo apt purge -y mysql-server mysql-client mysql-common 2>/dev/null || true
47 | sudo apt autoremove -y
48 | sudo rm -rf /var/lib/mysql 2>/dev/null || true
49 | sudo rm -rf /etc/mysql 2>/dev/null || true
50 | ;;
51 | "pacman"|"yay")
52 | sudo systemctl stop mysqld 2>/dev/null || true
53 | sudo pacman -Rs --noconfirm mysql 2>/dev/null || true
54 | ;;
55 | "dnf")
56 | sudo systemctl stop mysqld 2>/dev/null || true
57 | sudo dnf remove -y mysql-server mysql 2>/dev/null || true
58 | ;;
59 | *)
60 | log_warning "Purge not implemented for package manager: $pm"
61 | ;;
62 | esac
63 | fi
64 |
65 | # Install MySQL
66 | case "$pm" in
67 | "apt")
68 | install_mysql_apt "$mysql_major_minor"
69 | ;;
70 | "pacman")
71 | sudo pacman -S --noconfirm mysql
72 | ;;
73 | "yay")
74 | yay -S --noconfirm mysql
75 | ;;
76 | "dnf")
77 | sudo dnf install -y mysql-server mysql
78 | ;;
79 | "zypper")
80 | sudo zypper install -y mysql mysql-server
81 | ;;
82 | "brew")
83 | brew install mysql
84 | ;;
85 | *)
86 | log_error "Unsupported package manager: $pm"
87 | return 1
88 | ;;
89 | esac
90 |
91 | log_success "MySQL installed successfully"
92 | }
93 |
94 | install_mysql_apt() {
95 | local mysql_version="$1"
96 |
97 | log_step "Installing MySQL via APT"
98 |
99 | # Pre-configure MySQL to avoid interactive prompts
100 | local mysql_root_password="root"
101 |
102 | # Set MySQL root password
103 | echo "mysql-server mysql-server/root_password password $mysql_root_password" | sudo debconf-set-selections
104 | echo "mysql-server mysql-server/root_password_again password $mysql_root_password" | sudo debconf-set-selections
105 |
106 | # Update package list
107 | sudo apt update
108 |
109 | # Install MySQL
110 | sudo DEBIAN_FRONTEND=noninteractive apt install -y \
111 | mysql-server \
112 | mysql-client \
113 | mysql-common \
114 | libmysqlclient-dev
115 |
116 | log_success "MySQL installed via APT"
117 | }
118 |
119 | configure_mysql() {
120 | log_step "Configuring MySQL"
121 |
122 | # Start MySQL service
123 | if command -v systemctl >/dev/null 2>&1; then
124 | sudo systemctl enable mysql 2>/dev/null || sudo systemctl enable mysqld 2>/dev/null || true
125 | sudo systemctl start mysql 2>/dev/null || sudo systemctl start mysqld 2>/dev/null || true
126 | log_success "MySQL service started and enabled"
127 | else
128 | # Fallback for systems without systemctl
129 | sudo service mysql start 2>/dev/null || sudo service mysqld start 2>/dev/null || true
130 | log_success "MySQL service started"
131 | fi
132 |
133 | # Wait for MySQL to be ready
134 | log_step "Waiting for MySQL to be ready"
135 | local max_attempts=30
136 | local attempt=1
137 |
138 | while [[ $attempt -le $max_attempts ]]; do
139 | if mysqladmin ping -u root --password=root >/dev/null 2>&1; then
140 | log_success "MySQL is ready"
141 | break
142 | fi
143 |
144 | if [[ $attempt -eq $max_attempts ]]; then
145 | log_warning "MySQL may not be fully ready, continuing..."
146 | break
147 | fi
148 |
149 | log_info "Attempt $attempt/$max_attempts - waiting for MySQL..."
150 | sleep 2
151 | ((attempt++))
152 | done
153 |
154 | # Configure MySQL for remote access
155 | configure_mysql_remote_access
156 |
157 | # Create development user
158 | create_development_user
159 |
160 | # Configure MySQL settings
161 | configure_mysql_settings
162 | }
163 |
164 | configure_mysql_remote_access() {
165 | log_step "Configuring MySQL for remote access"
166 |
167 | local mysql_config="/etc/mysql/mysql.conf.d/mysqld.cnf"
168 | local mysql_config_alt="/etc/mysql/my.cnf"
169 |
170 | # Find MySQL config file
171 | local config_file=""
172 | if [[ -f "$mysql_config" ]]; then
173 | config_file="$mysql_config"
174 | elif [[ -f "$mysql_config_alt" ]]; then
175 | config_file="$mysql_config_alt"
176 | else
177 | log_warning "MySQL config file not found, skipping remote access configuration"
178 | return
179 | fi
180 |
181 | # Backup original config
182 | sudo cp "$config_file" "$config_file.backup.$(date +%Y%m%d_%H%M%S)"
183 |
184 | # Allow remote connections
185 | sudo sed -i 's/bind-address.*=.*/bind-address = 0.0.0.0/' "$config_file"
186 |
187 | log_success "MySQL configured for remote access"
188 | }
189 |
190 | create_development_user() {
191 | log_step "Creating development user"
192 |
193 | # Create a development user with full privileges
194 | local dev_user="dev"
195 | local dev_password="dev123"
196 |
197 | mysql -u root --password=root -e "
198 | CREATE USER IF NOT EXISTS '${dev_user}'@'localhost' IDENTIFIED BY '${dev_password}';
199 | GRANT ALL PRIVILEGES ON *.* TO '${dev_user}'@'localhost' WITH GRANT OPTION;
200 | CREATE USER IF NOT EXISTS '${dev_user}'@'%' IDENTIFIED BY '${dev_password}';
201 | GRANT ALL PRIVILEGES ON *.* TO '${dev_user}'@'%' WITH GRANT OPTION;
202 | FLUSH PRIVILEGES;
203 | " 2>/dev/null || log_warning "Failed to create development user"
204 |
205 | log_success "Development user created: $dev_user / $dev_password"
206 | }
207 |
208 | configure_mysql_settings() {
209 | log_step "Configuring MySQL settings"
210 |
211 | # Run mysql_secure_installation equivalent
212 | mysql -u root --password=root -e "
213 | DELETE FROM mysql.user WHERE User='';
214 | DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
215 | DROP DATABASE IF EXISTS test;
216 | DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
217 | FLUSH PRIVILEGES;
218 | " 2>/dev/null || log_warning "Failed to run security configuration"
219 |
220 | log_success "MySQL security settings applied"
221 | }
222 |
223 | create_mysql_aliases() {
224 | log_step "Creating MySQL aliases"
225 |
226 | local bashrc="$HOME/.bashrc"
227 | local aliases_section="# MySQL aliases added by matbrgz dotfiles"
228 |
229 | # Check if aliases already exist
230 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
231 | log_info "MySQL aliases already exist in $bashrc"
232 | return 0
233 | fi
234 |
235 | # Add MySQL aliases
236 | cat >> "$bashrc" << 'EOF'
237 |
238 | # MySQL aliases added by matbrgz dotfiles
239 | alias mysql-root='mysql -u root -p'
240 | alias mysql-dev='mysql -u dev -p'
241 | alias mysql-status='sudo systemctl status mysql'
242 | alias mysql-start='sudo systemctl start mysql'
243 | alias mysql-stop='sudo systemctl stop mysql'
244 | alias mysql-restart='sudo systemctl restart mysql'
245 | alias mysql-logs='sudo journalctl -u mysql -f'
246 | alias mysql-config='sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf'
247 |
248 | # MySQL helpers
249 | alias mysql-show-dbs='mysql -u root -p -e "SHOW DATABASES;"'
250 | alias mysql-show-users='mysql -u root -p -e "SELECT User, Host FROM mysql.user;"'
251 | alias mysql-processlist='mysql -u root -p -e "SHOW PROCESSLIST;"'
252 | alias mysql-variables='mysql -u root -p -e "SHOW VARIABLES;"'
253 | alias mysql-backup='mysqldump -u root -p --all-databases'
254 | EOF
255 |
256 | log_success "MySQL aliases added to $bashrc"
257 | }
258 |
259 | install_mysql_tools() {
260 | log_step "Installing MySQL tools"
261 |
262 | local pm
263 | pm=$(detect_package_manager)
264 |
265 | case "$pm" in
266 | "apt")
267 | sudo apt install -y mysql-workbench 2>/dev/null || log_info "MySQL Workbench not available in repositories"
268 | ;;
269 | "pacman")
270 | sudo pacman -S --noconfirm mysql-workbench 2>/dev/null || log_info "MySQL Workbench not available"
271 | ;;
272 | "brew")
273 | brew install --cask mysql-workbench 2>/dev/null || log_info "MySQL Workbench not available"
274 | ;;
275 | *)
276 | log_info "MySQL Workbench installation not configured for $pm"
277 | ;;
278 | esac
279 | }
280 |
281 | verify_installation() {
282 | log_step "Verifying MySQL installation"
283 |
284 | # Check if MySQL service is running
285 | if systemctl is-active --quiet mysql 2>/dev/null || systemctl is-active --quiet mysqld 2>/dev/null; then
286 | log_success "MySQL service is running"
287 | else
288 | log_warning "MySQL service status unclear"
289 | fi
290 |
291 | # Check MySQL version
292 | if command -v mysql >/dev/null 2>&1; then
293 | local version
294 | version=$(mysql --version)
295 | log_success "MySQL version: $version"
296 |
297 | # Test connection
298 | if mysql -u root --password=root -e "SELECT 1;" >/dev/null 2>&1; then
299 | log_success "MySQL root connection successful"
300 | else
301 | log_warning "MySQL root connection failed"
302 | fi
303 |
304 | # Test development user
305 | if mysql -u dev --password=dev123 -e "SELECT 1;" >/dev/null 2>&1; then
306 | log_success "MySQL development user connection successful"
307 | else
308 | log_warning "MySQL development user connection failed"
309 | fi
310 |
311 | else
312 | log_error "MySQL client not found"
313 | return 1
314 | fi
315 | }
316 |
317 | show_usage() {
318 | echo
319 | log_info "MySQL usage:"
320 | echo " - Connect as root: mysql-root"
321 | echo " - Connect as dev: mysql-dev"
322 | echo " - Service control: mysql-start, mysql-stop, mysql-restart"
323 | echo " - View logs: mysql-logs"
324 | echo " - Edit config: mysql-config"
325 | echo " - Show databases: mysql-show-dbs"
326 | echo " - Show users: mysql-show-users"
327 | echo
328 | log_info "Default credentials:"
329 | echo " - Root user: root / root"
330 | echo " - Dev user: dev / dev123"
331 | echo
332 | log_info "Configuration:"
333 | echo " - Config file: /etc/mysql/mysql.conf.d/mysqld.cnf"
334 | echo " - Data directory: /var/lib/mysql"
335 | echo " - Default port: 3306"
336 | echo " - Remote access: enabled (bind-address: 0.0.0.0)"
337 | echo
338 | log_info "Security recommendations:"
339 | echo " - Change default passwords"
340 | echo " - Limit remote access if not needed"
341 | echo " - Regular backups: mysql-backup > backup.sql"
342 | }
343 |
344 | main() {
345 | log_info "Starting MySQL setup"
346 |
347 | install_mysql
348 | configure_mysql
349 | create_mysql_aliases
350 | install_mysql_tools
351 | verify_installation
352 | show_usage
353 |
354 | log_success "MySQL setup completed successfully"
355 | log_info "Use 'source ~/.bashrc' to load new aliases"
356 | }
357 |
358 | # Run main function if script is executed directly
359 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
360 | main "$@"
361 | fi
362 |
--------------------------------------------------------------------------------
/programs/netkit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | NETKIT_VERSION="$(jq -r '.NETKIT_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
9 | NETKITFS_VERSION="$(jq -r '.NETKITFS_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
10 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
11 | echo "NetKit purge not implemented yet! Skipping."
12 | fi
13 | if ! curl http://wiki.netkit.org/download/netkit/netkit-"${NETKIT_VERSION}".tar.bz2; then
14 | echo "NetKit part 1 Download failed! Exiting."
15 | kill $$
16 | fi
17 | tar -xjSf netkit-"${NETKIT_VERSION}".tar.bz2
18 | if ! curl http://wiki.netkit.org/download/netkit-filesystem/netkit-filesystem-i386-F"${NETKITFS_VERSION}".tar.bz2; then
19 | echo "NetKit part 2 Download failed! Exiting."
20 | kill $$
21 | fi
22 | tar -xjSf netkit-filesystem-i386-F"${NETKITFS_VERSION}".tar.bz2
23 | if ! curl http://wiki.netkit.org/download/netkit-kernel/netkit-kernel-i386-K"${NETKIT_VERSION}".tar.bz2; then
24 | echo "NetKit part 3 Download failed! Exiting."
25 | kill $$
26 | fi
27 | tar -xjSf netkit-kernel-i386-K"${NETKIT_VERSION}".tar.bz2
28 | {
29 | #NetKit Config
30 | export NETKIT_HOME="${HOME}"/netkit
31 | export MANPATH=:${NETKIT_HOME}/man
32 | export PATH=${PATH}:${NETKIT_HOME}/bin
33 |
34 | } >>"${HOME}"/.bashrc
35 | chmod a+x /netkit/check_configuration.sh
36 | ./netkit/check_configuration.sh
37 |
--------------------------------------------------------------------------------
/programs/nginx.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # NGINX INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure Nginx web server
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_nginx() {
19 | log_step "Installing Nginx"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing Nginx installation"
27 | case "$pm" in
28 | "apt")
29 | sudo apt remove -y nginx nginx-common nginx-core 2>/dev/null || true
30 | sudo apt autoremove -y
31 | ;;
32 | "pacman"|"yay")
33 | sudo pacman -Rs --noconfirm nginx 2>/dev/null || true
34 | ;;
35 | "dnf")
36 | sudo dnf remove -y nginx 2>/dev/null || true
37 | ;;
38 | *)
39 | log_warning "Purge not implemented for package manager: $pm"
40 | ;;
41 | esac
42 | fi
43 |
44 | # Install Nginx
45 | case "$pm" in
46 | "apt")
47 | sudo apt update
48 | sudo apt install -y nginx
49 | ;;
50 | "pacman")
51 | sudo pacman -S --noconfirm nginx
52 | ;;
53 | "yay")
54 | yay -S --noconfirm nginx
55 | ;;
56 | "dnf")
57 | sudo dnf install -y nginx
58 | ;;
59 | "zypper")
60 | sudo zypper install -y nginx
61 | ;;
62 | "snap")
63 | sudo snap install nginx
64 | ;;
65 | "brew")
66 | brew install nginx
67 | ;;
68 | *)
69 | log_error "Unsupported package manager: $pm"
70 | return 1
71 | ;;
72 | esac
73 |
74 | log_success "Nginx installed successfully"
75 | }
76 |
77 | configure_nginx() {
78 | log_step "Configuring Nginx"
79 |
80 | # Get default folder from settings
81 | local default_folder
82 | local os_type
83 | os_type=$(detect_os)
84 | default_folder=$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".personal.defaultfolder.$os_type")
85 |
86 | if [[ "$default_folder" == "null" ]]; then
87 | default_folder="$HOME/dev"
88 | log_warning "Default folder not set in settings, using: $default_folder"
89 | fi
90 |
91 | # Expand tilde to full path
92 | default_folder="${default_folder/#\~/$HOME}"
93 |
94 | # Create default folder if it doesn't exist
95 | if [[ ! -d "$default_folder" ]]; then
96 | mkdir -p "$default_folder"
97 | log_info "Created default folder: $default_folder"
98 | fi
99 |
100 | # Create a simple index.html
101 | cat > "$default_folder/index.html" << 'EOF'
102 |
103 |
104 |
105 | Welcome to Nginx!
106 |
110 |
111 |
112 |
113 |
🚀 Nginx is working!
114 |
This is a custom development server configured by matbrgz dotfiles.
115 |
Document root: DEFAULT_FOLDER
116 |
117 |
118 |
119 | EOF
120 |
121 | # Replace placeholder with actual path
122 | sed -i "s|DEFAULT_FOLDER|$default_folder|g" "$default_folder/index.html"
123 |
124 | # Create custom Nginx config
125 | local nginx_config="/etc/nginx/sites-available/development"
126 |
127 | if [[ -d "/etc/nginx/sites-available" ]]; then
128 | log_step "Creating development site configuration"
129 |
130 | sudo tee "$nginx_config" > /dev/null << EOF
131 | server {
132 | listen 8080;
133 | listen [::]:8080;
134 |
135 | server_name localhost;
136 | root $default_folder;
137 | index index.html index.htm index.php;
138 |
139 | # Enable directory listing
140 | autoindex on;
141 | autoindex_exact_size off;
142 | autoindex_localtime on;
143 |
144 | location / {
145 | try_files \$uri \$uri/ =404;
146 | }
147 |
148 | # PHP support (if PHP is installed)
149 | location ~ \.php$ {
150 | include snippets/fastcgi-php.conf;
151 | fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
152 | }
153 |
154 | # Security headers
155 | add_header X-Frame-Options "SAMEORIGIN" always;
156 | add_header X-XSS-Protection "1; mode=block" always;
157 | add_header X-Content-Type-Options "nosniff" always;
158 |
159 | # Deny access to hidden files
160 | location ~ /\. {
161 | deny all;
162 | }
163 | }
164 | EOF
165 |
166 | # Enable the site
167 | sudo ln -sf "$nginx_config" /etc/nginx/sites-enabled/development
168 |
169 | # Disable default site to avoid conflicts
170 | sudo rm -f /etc/nginx/sites-enabled/default
171 |
172 | log_success "Development site configured on port 8080"
173 | else
174 | log_warning "sites-available directory not found, using default config"
175 | fi
176 | }
177 |
178 | start_nginx_service() {
179 | log_step "Starting Nginx service"
180 |
181 | # Test configuration
182 | if sudo nginx -t 2>/dev/null; then
183 | log_success "Nginx configuration test passed"
184 | else
185 | log_error "Nginx configuration test failed"
186 | return 1
187 | fi
188 |
189 | # Start and enable service
190 | if command -v systemctl >/dev/null 2>&1; then
191 | sudo systemctl enable nginx
192 | sudo systemctl restart nginx
193 | log_success "Nginx service started and enabled"
194 | else
195 | # Fallback for systems without systemctl
196 | sudo service nginx restart
197 | log_success "Nginx service restarted"
198 | fi
199 | }
200 |
201 | verify_installation() {
202 | log_step "Verifying Nginx installation"
203 |
204 | # Check if Nginx is running
205 | if systemctl is-active --quiet nginx 2>/dev/null; then
206 | log_success "Nginx service is running"
207 | else
208 | log_warning "Nginx service status unclear"
209 | fi
210 |
211 | # Check version
212 | if command -v nginx >/dev/null 2>&1; then
213 | local version
214 | version=$(nginx -v 2>&1 | cut -d'/' -f2)
215 | log_success "Nginx version: $version"
216 | fi
217 |
218 | # Test HTTP response
219 | if curl -s http://localhost:8080 >/dev/null 2>&1; then
220 | log_success "Nginx is responding on http://localhost:8080"
221 | else
222 | log_warning "Nginx is not responding on port 8080"
223 | fi
224 | }
225 |
226 | main() {
227 | log_info "Starting Nginx setup"
228 |
229 | install_nginx
230 | configure_nginx
231 | start_nginx_service
232 | verify_installation
233 |
234 | log_success "Nginx setup completed successfully"
235 | log_info "Access your development server at: http://localhost:8080"
236 | }
237 |
238 | # Run main function if script is executed directly
239 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
240 | main "$@"
241 | fi
242 |
--------------------------------------------------------------------------------
/programs/nvm-config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | export NVM_DIR="$HOME/.nvm"
9 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
10 | [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
11 | nvm install --lts
12 | nvm use --lts
13 | npm install -g yarn
14 | echo "alias ss=\"script/server\"" >>"${HOME}"/.bash_aliases
15 |
--------------------------------------------------------------------------------
/programs/nvm.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # NVM (NODE VERSION MANAGER) INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Node Version Manager for managing multiple Node.js versions
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_nvm() {
19 | log_step "Installing NVM (Node Version Manager)"
20 |
21 | # Get NVM version from version.json
22 | local nvm_version
23 | nvm_version=$(get_json_value "$PROJECT_ROOT/bootstrap/version.json" ".nvm")
24 |
25 | if [[ "$nvm_version" == "null" ]]; then
26 | log_warning "NVM version not found in version.json, using v0.39.8"
27 | nvm_version="0.39.8"
28 | fi
29 |
30 | # Check if purge mode is enabled
31 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
32 | log_step "Purging existing NVM installation"
33 | rm -rf "$HOME/.nvm" 2>/dev/null || true
34 | # Remove NVM lines from shell profiles
35 | sed -i '/NVM_DIR/d' "$HOME/.bashrc" 2>/dev/null || true
36 | sed -i '/nvm.sh/d' "$HOME/.bashrc" 2>/dev/null || true
37 | sed -i '/bash_completion/d' "$HOME/.bashrc" 2>/dev/null || true
38 | fi
39 |
40 | # Check if NVM is already installed
41 | if [[ -d "$HOME/.nvm" ]]; then
42 | log_info "NVM directory already exists, updating..."
43 | fi
44 |
45 | # Download and install NVM
46 | local install_url="https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh"
47 |
48 | log_info "Downloading NVM v${nvm_version}"
49 |
50 | if curl -o- "$install_url" | bash; then
51 | log_success "NVM v${nvm_version} installed successfully"
52 | else
53 | log_error "Failed to install NVM"
54 | return 1
55 | fi
56 | }
57 |
58 | configure_nvm() {
59 | log_step "Configuring NVM"
60 |
61 | # Ensure NVM configuration is in .bashrc
62 | local bashrc="$HOME/.bashrc"
63 | local nvm_config="# NVM configuration added by matbrgz dotfiles"
64 |
65 | # Check if NVM config already exists
66 | if ! grep -q "$nvm_config" "$bashrc" 2>/dev/null; then
67 | cat >> "$bashrc" << 'EOF'
68 |
69 | # NVM configuration added by matbrgz dotfiles
70 | export NVM_DIR="$HOME/.nvm"
71 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
72 | [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
73 |
74 | # NVM aliases
75 | alias nvm-install-lts='nvm install --lts'
76 | alias nvm-use-lts='nvm use --lts'
77 | alias nvm-install-latest='nvm install node'
78 | alias nvm-use-latest='nvm use node'
79 | alias nvm-list='nvm list'
80 | alias nvm-current='nvm current'
81 | EOF
82 |
83 | log_success "NVM configuration added to $bashrc"
84 | else
85 | log_info "NVM configuration already exists in $bashrc"
86 | fi
87 |
88 | # Load NVM for current session
89 | export NVM_DIR="$HOME/.nvm"
90 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
91 | }
92 |
93 | install_node_versions() {
94 | log_step "Installing Node.js versions"
95 |
96 | # Load NVM
97 | export NVM_DIR="$HOME/.nvm"
98 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
99 |
100 | if ! command -v nvm >/dev/null 2>&1; then
101 | log_error "NVM not available in current session"
102 | log_info "Please restart your shell or run: source ~/.bashrc"
103 | return 1
104 | fi
105 |
106 | # Get Node version from version.json
107 | local node_version
108 | node_version=$(get_json_value "$PROJECT_ROOT/bootstrap/version.json" ".node")
109 |
110 | if [[ "$node_version" == "null" ]]; then
111 | log_warning "Node version not found in version.json, installing LTS"
112 | # Install latest LTS
113 | nvm install --lts
114 | nvm use --lts
115 | nvm alias default lts/*
116 | else
117 | # Install specific version from version.json
118 | log_info "Installing Node.js v${node_version}"
119 | nvm install "$node_version"
120 | nvm use "$node_version"
121 | nvm alias default "$node_version"
122 | fi
123 |
124 | # Also install latest LTS as backup
125 | log_info "Installing latest LTS version"
126 | nvm install --lts
127 |
128 | log_success "Node.js versions installed"
129 | }
130 |
131 | install_global_packages() {
132 | log_step "Installing global npm packages"
133 |
134 | # Load NVM
135 | export NVM_DIR="$HOME/.nvm"
136 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
137 |
138 | local global_packages=(
139 | "yarn"
140 | "pnpm"
141 | "npm-check-updates"
142 | "nodemon"
143 | "pm2"
144 | "serve"
145 | "http-server"
146 | "live-server"
147 | "prettier"
148 | "eslint"
149 | "typescript"
150 | "@vue/cli"
151 | "@angular/cli"
152 | "create-react-app"
153 | "gatsby-cli"
154 | "@nestjs/cli"
155 | )
156 |
157 | for package in "${global_packages[@]}"; do
158 | log_info "Installing $package"
159 | npm install -g "$package" --silent
160 | done
161 |
162 | log_success "Global npm packages installed"
163 | }
164 |
165 | verify_installation() {
166 | log_step "Verifying NVM installation"
167 |
168 | # Load NVM
169 | export NVM_DIR="$HOME/.nvm"
170 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
171 |
172 | if command -v nvm >/dev/null 2>&1; then
173 | local nvm_version
174 | nvm_version=$(nvm --version)
175 | log_success "NVM version: $nvm_version"
176 |
177 | # Check Node.js
178 | if command -v node >/dev/null 2>&1; then
179 | local node_version
180 | node_version=$(node --version)
181 | log_success "Node.js version: $node_version"
182 | else
183 | log_warning "Node.js not available"
184 | fi
185 |
186 | # Check npm
187 | if command -v npm >/dev/null 2>&1; then
188 | local npm_version
189 | npm_version=$(npm --version)
190 | log_success "npm version: $npm_version"
191 | else
192 | log_warning "npm not available"
193 | fi
194 |
195 | # List installed versions
196 | log_info "Installed Node.js versions:"
197 | nvm list
198 |
199 | else
200 | log_error "NVM not found"
201 | log_info "Please restart your shell or run: source ~/.bashrc"
202 | return 1
203 | fi
204 | }
205 |
206 | show_usage() {
207 | echo
208 | log_info "NVM usage:"
209 | echo " - List available versions: nvm list-remote"
210 | echo " - Install latest LTS: nvm-install-lts"
211 | echo " - Install specific version: nvm install 18.17.0"
212 | echo " - Use version: nvm use 18.17.0"
213 | echo " - Use LTS: nvm-use-lts"
214 | echo " - Set default: nvm alias default 18.17.0"
215 | echo " - List installed: nvm-list"
216 | echo " - Current version: nvm-current"
217 | echo
218 | log_info "Global packages installed:"
219 | echo " - yarn, pnpm, nodemon, pm2, serve, prettier, eslint, typescript"
220 | echo " - Framework CLIs: @vue/cli, @angular/cli, create-react-app, gatsby-cli, @nestjs/cli"
221 | }
222 |
223 | main() {
224 | log_info "Starting NVM setup"
225 |
226 | install_nvm
227 | configure_nvm
228 | install_node_versions
229 | install_global_packages
230 | verify_installation
231 | show_usage
232 |
233 | log_success "NVM setup completed successfully"
234 | log_info "Restart your shell or run 'source ~/.bashrc' to use NVM"
235 | }
236 |
237 | # Run main function if script is executed directly
238 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
239 | main "$@"
240 | fi
241 |
--------------------------------------------------------------------------------
/programs/pgadmin.ps1:
--------------------------------------------------------------------------------
1 | cinst -y pgadmin4
--------------------------------------------------------------------------------
/programs/php-composer.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | if ! curl https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer |
9 | sudo php -- --install-dir=/usr/local/bin --filename=composer --quite; then
10 | echo "PHP Composer Download failed! Exiting."
11 | kill $$
12 | fi
13 | sudo chown -R "${USER}" ~/.composer/
14 |
--------------------------------------------------------------------------------
/programs/php-laravel.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | composer global require "laravel/installer"
9 | #TODO: Need refactory this if
10 | if [ "$(jq -r '.programs[].mysql.instalation' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
11 | printf "\n [ START ] Laravel Default MySQL Configuration\n"
12 | starttime=$(date +%s)
13 | echo " [ DOING ] Setting Laravel Default .env DB user on MySQL (user & db 'homestead', password 'secret')"
14 | mysql -u root -p -e "CREATE DATABASE homestead /*\!40100 DEFAULT CHARACTER SET utf8 */;"
15 | mysql -u root -p -e "CREATE USER homestead@localhost IDENTIFIED BY 'secret';"
16 | mysql -u root -p -e "GRANT ALL PRIVILEGES ON homestead.* TO 'homestead'@'localhost';"
17 | mysql -u root -p -e "FLUSH PRIVILEGES;"
18 | endtime=$(date +%s)
19 | printf " [ DONE ] Laravel Default MySQL Configuration ... %s seconds\n" "$((endtime - starttime))"
20 | fi
21 |
--------------------------------------------------------------------------------
/programs/pip-beautysh.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | pip install beautysh
9 |
--------------------------------------------------------------------------------
/programs/polar.ps1:
--------------------------------------------------------------------------------
1 | cinst -y polar
--------------------------------------------------------------------------------
/programs/postgre-pgadmin.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ] ; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == y ] ; then
9 | sudo apt -y purge pgadmin*
10 | fi
11 | sudo apt -y install pgadmin"${PGADMIN_VERSION}"
12 | dpkg --get-selections | grep pgadmin"${PGADMIN_VERSION}"
13 |
--------------------------------------------------------------------------------
/programs/postgre-postgis.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | POSTGIS_VERSION="$(jq -r '.POSTGIS_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
9 | LIBGEOS_VERSION="$(jq -r '.LIBGEOS_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
10 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == y ]; then
11 | sudo apt -y purge libgeos-* proj-bin
12 | fi
13 | sudo apt -y remove postgresql postgresql-common
14 | sudo apt -y install libgeos-"${LIBGEOS_VERSION}"
15 | sudo apt -y install proj-bin
16 | if ! curl https://download.osgeo.org/postgis/source/postgis-"${POSTGIS_VERSION}".tar.gz; then
17 | echo "Download failed! Exiting."
18 | kill $$
19 | fi
20 | tar -xjSf postgis-"${POSTGIS_VERSION}".tar.gz
21 | cd postgis-"${POSTGIS_VERSION}"
22 | ./configure
23 | make
24 | make install
25 | #-- Enable PostGIS (includes raster)
26 | #CREATE EXTENSION postgis;
27 | #-- Enable Topology
28 | #CREATE EXTENSION postgis_topology;
29 | #-- Enable PostGIS Advanced 3D
30 | #-- and other geoprocessing algorithms
31 | #-- sfcgal not available with all distributions
32 | #CREATE EXTENSION postgis_sfcgal;
33 | #-- fuzzy matching needed for Tiger
34 | #CREATE EXTENSION fuzzystrmatch;
35 | #-- rule based standardizer
36 | #CREATE EXTENSION address_standardizer;
37 | #-- example rule data set
38 | #CREATE EXTENSION address_standardizer_data_us;
39 | #-- Enable US Tiger Geocoder
40 | #CREATE EXTENSION postgis_tiger_geocoder;
41 |
--------------------------------------------------------------------------------
/programs/protobuf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | HEADER_TYPE="$(uname -s)"
9 | ARCHITECTURE_TYPE="$(uname -m)"
10 | PROTOC_VERSION="$(jq -r '.APACHE_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
11 | if ! curl https://github.com/google/protobuf/releases/download/v"${PROTOC_VERSION}"/protoc-"${PROTOC_VERSION}"-"${HEADER_TYPE}"-"${ARCHITECTURE_TYPE}".zip; then
12 | echo "Protobuf download failed! Exiting."
13 | kill $$
14 | fi
15 | unzip protoc-"${PROTOC_VERSION}"-"${HEADER_TYPE}"-"${ARCHITECTURE_TYPE}".zip -o -d protoc3
16 | sudo mv protoc3/bin/* /usr/local/bin/
17 | sudo cp -r protoc3/include/. /usr/local/include/
18 | sudo chown "${USER}" /usr/local/bin/protoc
19 | sudo chown -R "${USER}" /usr/local/include/google
20 |
--------------------------------------------------------------------------------
/programs/pyenv-virtualenv.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | git clone https://github.com/pyenv/pyenv-virtualenv.git "$(pyenv root)"/plugins/pyenv-virtualenv
9 | echo "eval $(pyenv virtualenv-init -)" >>~/.bash_profile
10 | exec "$SHELL"
11 | virtualenv -p /usr/bin/python"${PYTHON_VERSION}" venv
12 | echo "alias venvstart=\"source ${VENV_PATH}/venv/bin/activate\"" >>"${HOME}"/.bash_aliases
13 | source ${VENV_PATH}/venv/bin/activate
14 |
--------------------------------------------------------------------------------
/programs/pyenv.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # PyEnv - Python Version Manager Setup Script
4 | # Modern script following the new dotfiles pattern with enhanced functionality
5 |
6 | set -euo pipefail
7 |
8 | # Source utility functions and project configuration
9 | PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
10 | source "$PROJECT_ROOT/lib/utils.sh"
11 |
12 | # Configuration
13 | SCRIPT_NAME="PyEnv Python Version Manager"
14 | CONFIG_FILE="$HOME/.bashrc"
15 |
16 | # Get version from version.json
17 | get_pyenv_version() {
18 | pyenv_version=$(get_json_value "pyenv")
19 | if [[ -z "$pyenv_version" || "$pyenv_version" == "null" ]]; then
20 | pyenv_version="2.4.22"
21 | fi
22 | echo "$pyenv_version"
23 | }
24 |
25 | get_python_version() {
26 | python_version=$(get_json_value "python")
27 | if [[ -z "$python_version" || "$python_version" == "null" ]]; then
28 | python_version="3.13.1"
29 | fi
30 | echo "$python_version"
31 | }
32 |
33 | # Check if PyEnv is already installed
34 | check_pyenv_installation() {
35 | if [[ -d "$HOME/.pyenv" ]] && command -v pyenv >/dev/null 2>&1; then
36 | log_warning "PyEnv is already installed"
37 | pyenv --version
38 | return 0
39 | fi
40 | return 1
41 | }
42 |
43 | # Install build dependencies
44 | install_build_dependencies() {
45 | log_step "Installing Python build dependencies"
46 |
47 | local package_manager
48 | package_manager=$(detect_package_manager)
49 |
50 | case $package_manager in
51 | apt)
52 | sudo apt-get update
53 | sudo apt-get install -y build-essential libssl-dev zlib1g-dev \
54 | libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
55 | libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \
56 | libffi-dev liblzma-dev
57 | ;;
58 | yay|pacman)
59 | sudo pacman -S --needed --noconfirm base-devel openssl zlib bzip2 \
60 | readline sqlite curl llvm ncurses xz tk libxml2 xmlsec libffi xz
61 | ;;
62 | dnf)
63 | sudo dnf groupinstall -y "Development Tools"
64 | sudo dnf install -y openssl-devel bzip2-devel libffi-devel \
65 | zlib-devel readline-devel sqlite-devel wget curl llvm \
66 | ncurses-devel xz-devel tk-devel libxml2-devel xmlsec1-devel
67 | ;;
68 | zypper)
69 | sudo zypper install -y -t pattern devel_basis
70 | sudo zypper install -y libopenssl-devel libbz2-devel libffi-devel \
71 | zlib-devel readline-devel sqlite3-devel wget curl llvm \
72 | ncurses-devel xz-devel tk-devel libxml2-devel xmlsec1-devel
73 | ;;
74 | brew)
75 | brew install openssl readline sqlite3 xz zlib tcl-tk libffi
76 | ;;
77 | *)
78 | log_warning "Package manager not supported for dependency installation"
79 | ;;
80 | esac
81 | }
82 |
83 | # Clone and install PyEnv
84 | install_pyenv() {
85 | log_step "Installing PyEnv"
86 |
87 | # Remove existing installation if corrupted
88 | if [[ -d "$HOME/.pyenv" ]] && ! command -v pyenv >/dev/null 2>&1; then
89 | log_warning "Removing corrupted PyEnv installation"
90 | rm -rf "$HOME/.pyenv"
91 | fi
92 |
93 | # Clone PyEnv repository
94 | if [[ ! -d "$HOME/.pyenv" ]]; then
95 | git clone https://github.com/pyenv/pyenv.git "$HOME/.pyenv"
96 |
97 | # Build PyEnv for better performance (optional but recommended)
98 | cd "$HOME/.pyenv" && src/configure && make -C src || true
99 | fi
100 | }
101 |
102 | # Configure shell environment
103 | configure_shell_environment() {
104 | log_step "Configuring shell environment"
105 |
106 | local shell_config
107 | case "${SHELL##*/}" in
108 | bash)
109 | shell_config="$HOME/.bashrc"
110 | ;;
111 | zsh)
112 | shell_config="$HOME/.zshrc"
113 | ;;
114 | fish)
115 | shell_config="$HOME/.config/fish/config.fish"
116 | ;;
117 | *)
118 | shell_config="$HOME/.bashrc"
119 | ;;
120 | esac
121 |
122 | # Create backup of shell config
123 | if [[ -f "$shell_config" ]]; then
124 | cp "$shell_config" "${shell_config}.backup.$(date +%Y%m%d_%H%M%S)"
125 | fi
126 |
127 | # Add PyEnv to shell configuration
128 | local pyenv_config="
129 | # PyEnv Configuration
130 | export PYENV_ROOT=\"\$HOME/.pyenv\"
131 | [[ -d \$PYENV_ROOT/bin ]] && export PATH=\"\$PYENV_ROOT/bin:\$PATH\"
132 | eval \"\$(pyenv init -)\"
133 | "
134 |
135 | if ! grep -q "PYENV_ROOT" "$shell_config" 2>/dev/null; then
136 | echo "$pyenv_config" >> "$shell_config"
137 | log_success "Added PyEnv configuration to $shell_config"
138 | fi
139 |
140 | # Source the configuration for current session
141 | export PYENV_ROOT="$HOME/.pyenv"
142 | export PATH="$PYENV_ROOT/bin:$PATH"
143 | if command -v pyenv >/dev/null 2>&1; then
144 | eval "$(pyenv init -)"
145 | fi
146 | }
147 |
148 | # Install Python versions
149 | install_python_versions() {
150 | log_step "Installing Python versions"
151 |
152 | local python_version
153 | python_version=$(get_python_version)
154 |
155 | # Verify PyEnv is working
156 | if ! command -v pyenv >/dev/null 2>&1; then
157 | log_error "PyEnv not found in PATH. Please restart your shell."
158 | return 1
159 | fi
160 |
161 | # Install latest Python version
162 | log_step "Installing Python $python_version"
163 | if ! pyenv versions --bare | grep -q "^${python_version}$"; then
164 | pyenv install "$python_version"
165 | log_success "Python $python_version installed successfully"
166 | else
167 | log_warning "Python $python_version is already installed"
168 | fi
169 |
170 | # Set global Python version
171 | pyenv global "$python_version"
172 | pyenv rehash
173 |
174 | # Verify installation
175 | log_step "Verifying Python installation"
176 | python --version
177 | pip --version
178 | }
179 |
180 | # Install useful Python packages
181 | install_python_packages() {
182 | log_step "Installing essential Python packages"
183 |
184 | # Upgrade pip first
185 | python -m pip install --upgrade pip
186 |
187 | # Essential packages
188 | local packages=(
189 | "virtualenv"
190 | "virtualenvwrapper"
191 | "pipenv"
192 | "poetry"
193 | "black"
194 | "flake8"
195 | "pylint"
196 | "mypy"
197 | "pytest"
198 | "pytest-cov"
199 | "jupyter"
200 | "ipython"
201 | "requests"
202 | "numpy"
203 | "pandas"
204 | )
205 |
206 | for package in "${packages[@]}"; do
207 | if ! python -m pip show "$package" >/dev/null 2>&1; then
208 | python -m pip install "$package"
209 | fi
210 | done
211 |
212 | log_success "Essential Python packages installed"
213 | }
214 |
215 | # Create useful aliases
216 | create_aliases() {
217 | log_step "Creating PyEnv aliases"
218 |
219 | local alias_file="$HOME/.bash_aliases"
220 |
221 | # Create aliases for PyEnv
222 | local pyenv_aliases="
223 | # PyEnv Aliases
224 | alias py='python'
225 | alias py3='python3'
226 | alias pip3='pip'
227 | alias pyver='python --version'
228 | alias pylist='pyenv versions'
229 | alias pylocal='pyenv local'
230 | alias pyglobal='pyenv global'
231 | alias pyinstall='pyenv install'
232 | alias pyuninstall='pyenv uninstall'
233 | alias pyrehash='pyenv rehash'
234 | alias pyvenv='python -m venv'
235 | alias pyactivate='source ./venv/bin/activate'
236 | alias pyfreeze='pip freeze > requirements.txt'
237 | alias pyreqs='pip install -r requirements.txt'
238 | "
239 |
240 | if [[ -f "$alias_file" ]]; then
241 | if ! grep -q "PyEnv Aliases" "$alias_file"; then
242 | echo "$pyenv_aliases" >> "$alias_file"
243 | fi
244 | else
245 | echo "$pyenv_aliases" > "$alias_file"
246 | fi
247 |
248 | # Source aliases in bashrc if not already done
249 | if [[ -f "$CONFIG_FILE" ]] && ! grep -q ".bash_aliases" "$CONFIG_FILE"; then
250 | echo "
251 | # Source bash aliases
252 | if [ -f ~/.bash_aliases ]; then
253 | . ~/.bash_aliases
254 | fi" >> "$CONFIG_FILE"
255 | fi
256 |
257 | log_success "PyEnv aliases created"
258 | }
259 |
260 | # Verify installation
261 | verify_installation() {
262 | log_step "Verifying PyEnv installation"
263 |
264 | if command -v pyenv >/dev/null 2>&1; then
265 | log_success "PyEnv installed successfully!"
266 | echo " Version: $(pyenv --version)"
267 | echo " Global Python: $(pyenv global)"
268 | echo " Available versions: $(pyenv versions --bare | tr '\n' ' ')"
269 | return 0
270 | else
271 | log_error "PyEnv installation failed"
272 | return 1
273 | fi
274 | }
275 |
276 | # Show usage instructions
277 | show_usage() {
278 | cat << 'EOF'
279 |
280 | PyEnv Usage Instructions:
281 | ========================
282 |
283 | Basic Commands:
284 | pyenv install Install Python version
285 | pyenv versions List installed versions
286 | pyenv global Set global Python version
287 | pyenv local Set local Python version for project
288 | pyenv shell Set Python version for current shell
289 |
290 | Example Usage:
291 | pyenv install 3.12.0 Install Python 3.12.0
292 | pyenv global 3.12.0 Use Python 3.12.0 globally
293 | pyenv local 3.11.5 Use Python 3.11.5 in current directory
294 |
295 | Virtual Environments:
296 | python -m venv myenv Create virtual environment
297 | source myenv/bin/activate Activate virtual environment
298 | deactivate Deactivate virtual environment
299 |
300 | Useful Aliases:
301 | py, py3 Python shortcuts
302 | pyver Check Python version
303 | pylist List installed versions
304 | pyvenv Create virtual environment
305 | pyactivate Activate local venv
306 | pyfreeze Export requirements.txt
307 | pyreqs Install from requirements.txt
308 |
309 | Configuration Files:
310 | ~/.pyenv/ PyEnv installation directory
311 | ~/.python-version Global Python version file
312 | .python-version Local Python version file (per project)
313 |
314 | For more information: https://github.com/pyenv/pyenv
315 |
316 | EOF
317 | }
318 |
319 | # Main execution
320 | main() {
321 | log_step "Starting $SCRIPT_NAME installation"
322 |
323 | # Check if already installed
324 | if check_pyenv_installation; then
325 | verify_installation
326 | show_usage
327 | return 0
328 | fi
329 |
330 | # Install dependencies and PyEnv
331 | install_build_dependencies
332 | install_pyenv
333 | configure_shell_environment
334 |
335 | # Wait a moment for shell configuration
336 | sleep 2
337 |
338 | # Install Python and packages
339 | install_python_versions
340 | install_python_packages
341 |
342 | # Setup aliases and verify
343 | create_aliases
344 |
345 | if verify_installation; then
346 | show_usage
347 | log_success "$SCRIPT_NAME installation completed!"
348 | log_warning "Please restart your shell or run: source ~/.bashrc"
349 | else
350 | log_error "$SCRIPT_NAME installation failed!"
351 | exit 1
352 | fi
353 | }
354 |
355 | # Execute main function
356 | main "$@"
357 |
--------------------------------------------------------------------------------
/programs/python-pip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # PYTHON PIP INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure Python pip package manager
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_pip() {
19 | log_step "Installing Python pip"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing pip installation"
27 | case "$pm" in
28 | "apt")
29 | sudo apt remove -y python3-pip python-pip 2>/dev/null || true
30 | sudo apt autoremove -y
31 | ;;
32 | "pacman"|"yay")
33 | sudo pacman -Rs --noconfirm python-pip 2>/dev/null || true
34 | ;;
35 | "dnf")
36 | sudo dnf remove -y python3-pip 2>/dev/null || true
37 | ;;
38 | *)
39 | log_warning "Purge not implemented for package manager: $pm"
40 | ;;
41 | esac
42 | fi
43 |
44 | # Check if Python3 is installed
45 | if ! command -v python3 >/dev/null 2>&1; then
46 | log_error "Python3 is required but not installed"
47 | log_info "Please install Python3 first using the python3.sh script"
48 | return 1
49 | fi
50 |
51 | # Install pip
52 | case "$pm" in
53 | "apt")
54 | sudo apt update
55 | sudo apt install -y python3-pip python3-setuptools python3-wheel
56 | ;;
57 | "pacman")
58 | sudo pacman -S --noconfirm python-pip python-setuptools python-wheel
59 | ;;
60 | "yay")
61 | yay -S --noconfirm python-pip python-setuptools python-wheel
62 | ;;
63 | "dnf")
64 | sudo dnf install -y python3-pip python3-setuptools python3-wheel
65 | ;;
66 | "zypper")
67 | sudo zypper install -y python3-pip python3-setuptools python3-wheel
68 | ;;
69 | "snap")
70 | # pip is usually included with python3 snap
71 | log_info "pip should be included with python3 snap package"
72 | ;;
73 | "brew")
74 | # pip is usually included with python3 from brew
75 | log_info "pip should be included with python3 from brew"
76 | ;;
77 | *)
78 | install_pip_get_pip
79 | ;;
80 | esac
81 |
82 | log_success "Python pip installed successfully"
83 | }
84 |
85 | install_pip_get_pip() {
86 | log_step "Installing pip using get-pip.py"
87 |
88 | local get_pip_url="https://bootstrap.pypa.io/get-pip.py"
89 | local temp_file="/tmp/get-pip.py"
90 |
91 | if curl -L "$get_pip_url" -o "$temp_file"; then
92 | python3 "$temp_file" --user
93 | rm -f "$temp_file"
94 | log_success "pip installed using get-pip.py"
95 | else
96 | log_error "Failed to download get-pip.py"
97 | return 1
98 | fi
99 | }
100 |
101 | configure_pip() {
102 | log_step "Configuring pip"
103 |
104 | # Upgrade pip to latest version
105 | log_step "Upgrading pip to latest version"
106 | python3 -m pip install --upgrade pip --user
107 |
108 | # Configure pip to use user directory by default
109 | local pip_conf_dir="$HOME/.config/pip"
110 | local pip_conf="$pip_conf_dir/pip.conf"
111 |
112 | mkdir -p "$pip_conf_dir"
113 |
114 | cat > "$pip_conf" << 'EOF'
115 | [global]
116 | user = true
117 | upgrade-strategy = eager
118 |
119 | [install]
120 | user = true
121 | EOF
122 |
123 | log_success "pip configuration created at $pip_conf"
124 |
125 | # Add user bin directory to PATH
126 | local user_bin_path="$HOME/.local/bin"
127 | if [[ ":$PATH:" != *":$user_bin_path:"* ]]; then
128 | echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"
129 | log_success "Added $user_bin_path to PATH in .bashrc"
130 | else
131 | log_info "User bin path already in PATH"
132 | fi
133 | }
134 |
135 | install_common_packages() {
136 | log_step "Installing common Python packages"
137 |
138 | local common_packages=(
139 | "setuptools"
140 | "wheel"
141 | "virtualenv"
142 | "pipenv"
143 | "black"
144 | "flake8"
145 | "pytest"
146 | "requests"
147 | "beautifulsoup4"
148 | "pandas"
149 | "numpy"
150 | )
151 |
152 | for package in "${common_packages[@]}"; do
153 | log_info "Installing $package"
154 | python3 -m pip install --user "$package" --quiet
155 | done
156 |
157 | log_success "Common Python packages installed"
158 | }
159 |
160 | create_python_aliases() {
161 | log_step "Creating Python/pip aliases"
162 |
163 | local bashrc="$HOME/.bashrc"
164 | local aliases_section="# Python/pip aliases added by matbrgz dotfiles"
165 |
166 | # Check if aliases already exist
167 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
168 | log_info "Python aliases already exist in $bashrc"
169 | return 0
170 | fi
171 |
172 | # Add Python aliases
173 | cat >> "$bashrc" << 'EOF'
174 |
175 | # Python/pip aliases added by matbrgz dotfiles
176 | alias py='python3'
177 | alias pip='python3 -m pip'
178 | alias pip-upgrade='python3 -m pip install --upgrade pip'
179 | alias pip-list='python3 -m pip list'
180 | alias pip-outdated='python3 -m pip list --outdated'
181 | alias pip-upgrade-all='python3 -m pip list --outdated --format=freeze | grep -v "^\-e" | cut -d = -f 1 | xargs -n1 python3 -m pip install -U'
182 | alias venv-create='python3 -m venv'
183 | alias venv-activate='source venv/bin/activate'
184 | alias serve-here='python3 -m http.server 8000'
185 | EOF
186 |
187 | log_success "Python aliases added to $bashrc"
188 | }
189 |
190 | verify_installation() {
191 | log_step "Verifying pip installation"
192 |
193 | if command -v python3 >/dev/null 2>&1; then
194 | local python_version
195 | python_version=$(python3 --version)
196 | log_success "Python version: $python_version"
197 | else
198 | log_error "Python3 not found"
199 | return 1
200 | fi
201 |
202 | if python3 -m pip --version >/dev/null 2>&1; then
203 | local pip_version
204 | pip_version=$(python3 -m pip --version)
205 | log_success "pip version: $pip_version"
206 | else
207 | log_error "pip not found"
208 | return 1
209 | fi
210 |
211 | # Test package installation
212 | if python3 -c "import setuptools" 2>/dev/null; then
213 | log_success "setuptools is available"
214 | else
215 | log_warning "setuptools is not available"
216 | fi
217 | }
218 |
219 | show_usage() {
220 | echo
221 | log_info "Python/pip usage:"
222 | echo " - Install package: pip install package_name"
223 | echo " - Install in user directory: pip install --user package_name"
224 | echo " - Upgrade pip: pip-upgrade"
225 | echo " - List packages: pip-list"
226 | echo " - Check outdated: pip-outdated"
227 | echo " - Create virtual env: venv-create myenv"
228 | echo " - Activate virtual env: source myenv/bin/activate"
229 | echo " - Start HTTP server: serve-here"
230 | }
231 |
232 | main() {
233 | log_info "Starting Python pip setup"
234 |
235 | install_pip
236 | configure_pip
237 | install_common_packages
238 | create_python_aliases
239 | verify_installation
240 | show_usage
241 |
242 | log_success "Python pip setup completed successfully"
243 | log_info "Use 'source ~/.bashrc' to load new aliases"
244 | }
245 |
246 | # Run main function if script is executed directly
247 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
248 | main "$@"
249 | fi
250 |
--------------------------------------------------------------------------------
/programs/python3.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # PYTHON 3 INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Python 3 with development tools
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_python3() {
19 | log_step "Installing Python 3"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Get Python version from version.json
25 | local python_version
26 | python_version=$(get_json_value "$PROJECT_ROOT/bootstrap/version.json" ".python")
27 |
28 | if [[ "$python_version" == "null" ]]; then
29 | log_warning "Python version not found in version.json, using default"
30 | python_version="3.11"
31 | fi
32 |
33 | # Extract major.minor version (e.g., "3.13.1" -> "3.13")
34 | local python_major_minor
35 | python_major_minor=$(echo "$python_version" | cut -d'.' -f1-2)
36 |
37 | log_info "Installing Python $python_major_minor"
38 |
39 | # Check if purge mode is enabled
40 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
41 | log_step "Purging existing Python installation"
42 | case "$pm" in
43 | "apt")
44 | sudo apt remove -y python3 python3-* 2>/dev/null || true
45 | sudo apt autoremove -y
46 | ;;
47 | "pacman"|"yay")
48 | sudo pacman -Rs --noconfirm python python-* 2>/dev/null || true
49 | ;;
50 | "dnf")
51 | sudo dnf remove -y python3 python3-* 2>/dev/null || true
52 | ;;
53 | *)
54 | log_warning "Purge not implemented for package manager: $pm"
55 | ;;
56 | esac
57 | fi
58 |
59 | # Install Python and development tools
60 | case "$pm" in
61 | "apt")
62 | # Add deadsnakes PPA for newer Python versions
63 | sudo apt update
64 | sudo apt install -y software-properties-common
65 | sudo add-apt-repository -y ppa:deadsnakes/ppa
66 | sudo apt update
67 |
68 | sudo apt install -y \
69 | "python${python_major_minor}" \
70 | "python${python_major_minor}-dev" \
71 | "python${python_major_minor}-venv" \
72 | "python${python_major_minor}-pip" \
73 | python3-setuptools \
74 | python3-wheel \
75 | python3-tk \
76 | build-essential \
77 | libffi-dev \
78 | libssl-dev \
79 | zlib1g-dev \
80 | libbz2-dev \
81 | libreadline-dev \
82 | libsqlite3-dev \
83 | libncurses5-dev \
84 | libncursesw5-dev \
85 | xz-utils \
86 | tk-dev \
87 | libgdbm-dev \
88 | libc6-dev \
89 | liblzma-dev
90 | ;;
91 | "pacman")
92 | sudo pacman -S --noconfirm \
93 | python \
94 | python-pip \
95 | python-setuptools \
96 | python-wheel \
97 | python-virtualenv \
98 | tk \
99 | base-devel \
100 | openssl \
101 | zlib \
102 | bzip2 \
103 | readline \
104 | sqlite \
105 | ncurses \
106 | xz \
107 | gdbm
108 | ;;
109 | "yay")
110 | yay -S --noconfirm \
111 | python \
112 | python-pip \
113 | python-setuptools \
114 | python-wheel \
115 | python-virtualenv \
116 | tk \
117 | base-devel
118 | ;;
119 | "dnf")
120 | sudo dnf install -y \
121 | python3 \
122 | python3-devel \
123 | python3-pip \
124 | python3-setuptools \
125 | python3-wheel \
126 | python3-virtualenv \
127 | python3-tkinter \
128 | gcc \
129 | gcc-c++ \
130 | make \
131 | openssl-devel \
132 | zlib-devel \
133 | bzip2-devel \
134 | readline-devel \
135 | sqlite-devel \
136 | ncurses-devel \
137 | xz-devel \
138 | tk-devel \
139 | gdbm-devel
140 | ;;
141 | "zypper")
142 | sudo zypper install -y \
143 | python3 \
144 | python3-devel \
145 | python3-pip \
146 | python3-setuptools \
147 | python3-wheel \
148 | python3-virtualenv \
149 | python3-tk \
150 | gcc \
151 | gcc-c++ \
152 | make
153 | ;;
154 | "snap")
155 | sudo snap install python38 --classic
156 | ;;
157 | "brew")
158 | brew install python@${python_major_minor}
159 | ;;
160 | *)
161 | log_error "Unsupported package manager: $pm"
162 | return 1
163 | ;;
164 | esac
165 |
166 | log_success "Python 3 installed successfully"
167 | }
168 |
169 | configure_python() {
170 | log_step "Configuring Python"
171 |
172 | # Create python3 symlink if needed
173 | if ! command -v python3 >/dev/null 2>&1; then
174 | # Try to find python binary
175 | for py_cmd in python3.13 python3.12 python3.11 python3.10 python3.9 python; do
176 | if command -v "$py_cmd" >/dev/null 2>&1; then
177 | sudo ln -sf "$(which $py_cmd)" /usr/local/bin/python3
178 | log_info "Created python3 symlink to $py_cmd"
179 | break
180 | fi
181 | done
182 | fi
183 |
184 | # Ensure pip is available
185 | if ! python3 -m pip --version >/dev/null 2>&1; then
186 | log_step "Installing pip"
187 | python3 -m ensurepip --default-pip --user
188 | fi
189 |
190 | # Upgrade pip
191 | python3 -m pip install --upgrade pip --user
192 |
193 | # Install essential Python tools
194 | local essential_packages=(
195 | "setuptools"
196 | "wheel"
197 | "virtualenv"
198 | "pipenv"
199 | "poetry"
200 | "black"
201 | "flake8"
202 | "pylint"
203 | "mypy"
204 | "pytest"
205 | "jupyter"
206 | "ipython"
207 | "requests"
208 | "beautifulsoup4"
209 | "lxml"
210 | "pyyaml"
211 | "python-dotenv"
212 | )
213 |
214 | log_step "Installing essential Python packages"
215 | for package in "${essential_packages[@]}"; do
216 | log_info "Installing $package"
217 | python3 -m pip install --user "$package" --quiet
218 | done
219 |
220 | log_success "Essential Python packages installed"
221 | }
222 |
223 | create_python_aliases() {
224 | log_step "Creating Python aliases"
225 |
226 | local bashrc="$HOME/.bashrc"
227 | local aliases_section="# Python aliases added by matbrgz dotfiles"
228 |
229 | # Check if aliases already exist
230 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
231 | log_info "Python aliases already exist in $bashrc"
232 | return 0
233 | fi
234 |
235 | # Add Python aliases
236 | cat >> "$bashrc" << 'EOF'
237 |
238 | # Python aliases added by matbrgz dotfiles
239 | alias py='python3'
240 | alias python='python3'
241 | alias pip='python3 -m pip'
242 | alias venv='python3 -m venv'
243 | alias activate='source venv/bin/activate'
244 | alias deactivate='deactivate'
245 | alias pstart='python3 -m http.server 8000'
246 | alias pyserver='python3 -m http.server'
247 | alias pytest='python3 -m pytest'
248 | alias black='python3 -m black'
249 | alias flake8='python3 -m flake8'
250 | alias mypy='python3 -m mypy'
251 | alias jupyter='python3 -m jupyter'
252 | alias ipython='python3 -m IPython'
253 |
254 | # Python project helpers
255 | alias pyclean='find . -type f -name "*.pyc" -delete && find . -type d -name "__pycache__" -delete'
256 | alias pyenv-create='python3 -m venv venv && source venv/bin/activate && pip install --upgrade pip'
257 | alias pyrequirements='pip freeze > requirements.txt'
258 | alias pyinstall='pip install -r requirements.txt'
259 | EOF
260 |
261 | log_success "Python aliases added to $bashrc"
262 | }
263 |
264 | verify_installation() {
265 | log_step "Verifying Python installation"
266 |
267 | if command -v python3 >/dev/null 2>&1; then
268 | local python_version
269 | python_version=$(python3 --version)
270 | log_success "Python version: $python_version"
271 |
272 | # Check pip
273 | if python3 -m pip --version >/dev/null 2>&1; then
274 | local pip_version
275 | pip_version=$(python3 -m pip --version)
276 | log_success "pip version: $pip_version"
277 | else
278 | log_warning "pip not available"
279 | fi
280 |
281 | # Check virtual environment
282 | if python3 -c "import venv" 2>/dev/null; then
283 | log_success "venv module available"
284 | else
285 | log_warning "venv module not available"
286 | fi
287 |
288 | # Check essential modules
289 | local modules=("setuptools" "wheel" "pip" "ssl" "sqlite3" "tkinter")
290 | for module in "${modules[@]}"; do
291 | if python3 -c "import $module" 2>/dev/null; then
292 | log_success "$module module available"
293 | else
294 | log_warning "$module module not available"
295 | fi
296 | done
297 |
298 | else
299 | log_error "Python3 not found"
300 | return 1
301 | fi
302 | }
303 |
304 | show_usage() {
305 | echo
306 | log_info "Python usage:"
307 | echo " - Run Python: py or python3"
308 | echo " - Install package: pip install package_name"
309 | echo " - Create virtual env: pyenv-create"
310 | echo " - Activate virtual env: activate"
311 | echo " - Run tests: pytest"
312 | echo " - Format code: black ."
313 | echo " - Lint code: flake8 ."
314 | echo " - Type check: mypy ."
315 | echo " - Start Jupyter: jupyter notebook"
316 | echo " - Start server: pstart (port 8000)"
317 | echo " - Clean bytecode: pyclean"
318 | echo
319 | log_info "Development workflow:"
320 | echo " 1. Create project: mkdir myproject && cd myproject"
321 | echo " 2. Create virtual env: pyenv-create"
322 | echo " 3. Install dependencies: pyinstall"
323 | echo " 4. Develop with: black, flake8, mypy, pytest"
324 | }
325 |
326 | main() {
327 | log_info "Starting Python 3 setup"
328 |
329 | install_python3
330 | configure_python
331 | create_python_aliases
332 | verify_installation
333 | show_usage
334 |
335 | log_success "Python 3 setup completed successfully"
336 | log_info "Use 'source ~/.bashrc' to load new aliases"
337 | }
338 |
339 | # Run main function if script is executed directly
340 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
341 | main "$@"
342 | fi
343 |
--------------------------------------------------------------------------------
/programs/qbittorrent.ps1:
--------------------------------------------------------------------------------
1 | cinst -y qbittorrent
--------------------------------------------------------------------------------
/programs/redis.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # REDIS INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure Redis server
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_redis() {
19 | log_step "Installing Redis"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing Redis installation"
27 | case "$pm" in
28 | "apt")
29 | sudo apt remove -y redis-server redis-tools 2>/dev/null || true
30 | sudo apt autoremove -y
31 | ;;
32 | "pacman"|"yay")
33 | sudo pacman -Rs --noconfirm redis 2>/dev/null || true
34 | ;;
35 | "dnf")
36 | sudo dnf remove -y redis 2>/dev/null || true
37 | ;;
38 | *)
39 | log_warning "Purge not implemented for package manager: $pm"
40 | ;;
41 | esac
42 | fi
43 |
44 | # Install Redis
45 | case "$pm" in
46 | "apt")
47 | sudo apt update
48 | sudo apt install -y redis-server redis-tools
49 | ;;
50 | "pacman")
51 | sudo pacman -S --noconfirm redis
52 | ;;
53 | "yay")
54 | yay -S --noconfirm redis
55 | ;;
56 | "dnf")
57 | sudo dnf install -y redis
58 | ;;
59 | "zypper")
60 | sudo zypper install -y redis
61 | ;;
62 | "snap")
63 | sudo snap install redis
64 | ;;
65 | "brew")
66 | brew install redis
67 | ;;
68 | *)
69 | log_error "Unsupported package manager: $pm"
70 | return 1
71 | ;;
72 | esac
73 |
74 | log_success "Redis installed successfully"
75 | }
76 |
77 | configure_redis() {
78 | log_step "Configuring Redis"
79 |
80 | # Start and enable Redis service
81 | if command -v systemctl >/dev/null 2>&1; then
82 | sudo systemctl enable redis-server 2>/dev/null || sudo systemctl enable redis 2>/dev/null || true
83 | sudo systemctl start redis-server 2>/dev/null || sudo systemctl start redis 2>/dev/null || true
84 | log_success "Redis service started and enabled"
85 | else
86 | log_warning "systemctl not available, skipping service configuration"
87 | fi
88 | }
89 |
90 | verify_installation() {
91 | log_step "Verifying Redis installation"
92 |
93 | if command -v redis-cli >/dev/null 2>&1; then
94 | local version
95 | version=$(redis-cli --version)
96 | log_success "Redis CLI version: $version"
97 |
98 | # Test connection
99 | if redis-cli ping >/dev/null 2>&1; then
100 | log_success "Redis server is running and responding"
101 | else
102 | log_warning "Redis server is not responding to ping"
103 | fi
104 | else
105 | log_error "Redis CLI not found"
106 | return 1
107 | fi
108 | }
109 |
110 | main() {
111 | log_info "Starting Redis setup"
112 |
113 | install_redis
114 | configure_redis
115 | verify_installation
116 |
117 | log_success "Redis setup completed successfully"
118 | }
119 |
120 | # Run main function if script is executed directly
121 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
122 | main "$@"
123 | fi
124 |
--------------------------------------------------------------------------------
/programs/rlang.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | RELEASE_VERSION="$(lsb_release -cs)"
9 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == y ]; then
10 | sudo apt -y purge rbase*
11 | fi
12 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
13 | sudo add-apt-repository "deb https://cloud.r-project.org/bin/${HEADER_TYPE}/ubuntu ${RELEASE_VERSION}-cran35/"
14 | sudo apt update
15 | sudo apt -y install r-base
16 | sudo -i R
17 |
--------------------------------------------------------------------------------
/programs/rstudio.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | RELEASE_VERSION="$(lsb_release -cs)"
9 | RSTUDIO_VERSION="$(jq -r '.RSTUDIO_VERSION' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
10 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == y ]; then
11 | sudo apt -y purge rbase*
12 | fi
13 | sudo apt update
14 | sudo apt install -y gdebi-core gfortran libgdal-dev libgeos-dev libpng-dev
15 | sudo apt-get install -y libjpeg62-dev libjpeg8-dev libcairo-dev libssl-dev
16 | if ! curl https://download2.rstudio.org/server/"${RELEASE_VERSION}"/amd64/rstudio-server-"${RSTUDIO_VERSION}"-amd64.deb -o rstudio-server-"${RSTUDIO_VERSION}"-amd64.deb && dpkg -i rstudio-server-"${RSTUDIO_VERSION}"-amd64.deb ; then
17 | echo "RStudio Download failed! Skipping."
18 | kill $$
19 | fi
20 | sudo gdebi rstudio-server-"${RSTUDIO_VERSION}"-amd64.deb
21 | if ! sudo curl /etc/init.d/rstudio-server \
22 | -L "https://raw.githubusercontent.com/rstudio/rstudio/master/src/cpp/server/extras/init.d/debian/rstudio-server.in"; then
23 | echo "RStudio Server Service Download failed! Skipping."
24 | kill $$
25 | fi
26 | sudo chmod 777 /etc/init.d/rstudio-server
27 | /etc/init.d/rstudio-server start
28 | adduser rstudio
29 | cd /usr/lib/rstudio-server/bin
30 | ./rsession --log-stderr 1
31 |
32 | cat /var/log/syslog
33 | cat /var/log/messages
34 | cat /var/lib/rstudio-server/monitor/log/rstudio-server.log
35 |
36 | cd "${HOME}"/tmp || return
37 |
38 | {
39 | # RStudio Config
40 | export R_HOME=/usr/lib/R #important! LIB not BIN, BIN is a .sh file
41 | export R_DOC_DIR=/usr/share/R/doc
42 | export R_INCLUDE_DIR=/usr/share/R/include
43 | export R_SHARE_DIR=/usr/share/R/share
44 | export EDITOR=vscode
45 |
46 | } >>"${HOME}"/.bashrc
47 |
48 |
49 |
--------------------------------------------------------------------------------
/programs/ruby-jekyll.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | gem install jekyll bundler
9 | echo "alias jstart=\"bundle exec jekyll serve --watch\"" >>"${HOME}"/.bash_aliases
10 |
--------------------------------------------------------------------------------
/programs/rvm-config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | RUBY_VERSION="$(jq -r '.RUBY_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"
9 | export PATH="${PATH}:$HOME/.rvm/bin"
10 | [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
11 | rvm install "${RUBY_VERSION}"
12 | /bin/bash --login
13 | rvm use "${RUBY_VERSION}"
14 | echo "alias gtest=\"testrb test/integration/bundle_test.rb\"" >>"${HOME}"/.bash_aliases
15 |
--------------------------------------------------------------------------------
/programs/sharex.ps1:
--------------------------------------------------------------------------------
1 | cinst -y sharex
--------------------------------------------------------------------------------
/programs/shellcheck.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # SHELLCHECK INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install ShellCheck static analysis tool for shell scripts
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_shellcheck() {
19 | log_step "Installing ShellCheck"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing ShellCheck installation"
27 | case "$pm" in
28 | "apt")
29 | sudo apt remove -y shellcheck 2>/dev/null || true
30 | sudo apt autoremove -y
31 | ;;
32 | "pacman"|"yay")
33 | sudo pacman -Rs --noconfirm shellcheck 2>/dev/null || true
34 | ;;
35 | "dnf")
36 | sudo dnf remove -y shellcheck 2>/dev/null || true
37 | ;;
38 | *)
39 | log_warning "Purge not implemented for package manager: $pm"
40 | ;;
41 | esac
42 | fi
43 |
44 | # Install ShellCheck
45 | case "$pm" in
46 | "apt")
47 | sudo apt update
48 | sudo apt install -y shellcheck
49 | ;;
50 | "pacman")
51 | sudo pacman -S --noconfirm shellcheck
52 | ;;
53 | "yay")
54 | yay -S --noconfirm shellcheck
55 | ;;
56 | "dnf")
57 | sudo dnf install -y shellcheck
58 | ;;
59 | "zypper")
60 | sudo zypper install -y shellcheck
61 | ;;
62 | "snap")
63 | sudo snap install shellcheck
64 | ;;
65 | "brew")
66 | brew install shellcheck
67 | ;;
68 | *)
69 | install_shellcheck_binary
70 | ;;
71 | esac
72 |
73 | log_success "ShellCheck installed successfully"
74 | }
75 |
76 | install_shellcheck_binary() {
77 | log_step "Installing ShellCheck from binary release"
78 |
79 | local architecture
80 | local shellcheck_version="v0.9.0"
81 |
82 | architecture=$(uname -m)
83 |
84 | # Map architecture names
85 | case "$architecture" in
86 | "x86_64")
87 | architecture="x86_64"
88 | ;;
89 | "aarch64"|"arm64")
90 | architecture="aarch64"
91 | ;;
92 | *)
93 | log_error "Unsupported architecture for binary installation: $architecture"
94 | return 1
95 | ;;
96 | esac
97 |
98 | local download_url="https://github.com/koalaman/shellcheck/releases/download/${shellcheck_version}/shellcheck-${shellcheck_version}.linux.${architecture}.tar.xz"
99 |
100 | log_info "Downloading ShellCheck ${shellcheck_version} for ${architecture}"
101 |
102 | # Download and extract
103 | if curl -L "$download_url" -o /tmp/shellcheck.tar.xz; then
104 | cd /tmp
105 | tar -xf shellcheck.tar.xz
106 | sudo mv "shellcheck-${shellcheck_version}/shellcheck" /usr/local/bin/
107 | sudo chmod +x /usr/local/bin/shellcheck
108 | rm -rf /tmp/shellcheck* "shellcheck-${shellcheck_version}"
109 |
110 | log_success "ShellCheck binary installed to /usr/local/bin/shellcheck"
111 | else
112 | log_error "Failed to download ShellCheck binary"
113 | return 1
114 | fi
115 | }
116 |
117 | configure_shellcheck() {
118 | log_step "Configuring ShellCheck"
119 |
120 | # Create a global .shellcheckrc for consistent configuration
121 | local shellcheck_config="$HOME/.shellcheckrc"
122 |
123 | cat > "$shellcheck_config" << 'EOF'
124 | # ShellCheck configuration file
125 | # Disable specific warnings that are often not relevant
126 |
127 | # SC2034: Variable appears unused
128 | disable=SC2034
129 |
130 | # SC1090: Can't follow non-constant source
131 | disable=SC1090
132 |
133 | # SC1091: Not following sourced files
134 | disable=SC1091
135 |
136 | # SC2155: Declare and assign separately
137 | disable=SC2155
138 |
139 | # Enable external sources checking
140 | external-sources=true
141 |
142 | # Set shell dialect (bash is default)
143 | shell=bash
144 | EOF
145 |
146 | log_success "ShellCheck configuration created at $shellcheck_config"
147 | }
148 |
149 | create_shellcheck_aliases() {
150 | log_step "Creating ShellCheck aliases"
151 |
152 | local bashrc="$HOME/.bashrc"
153 | local aliases_section="# ShellCheck aliases added by matbrgz dotfiles"
154 |
155 | # Check if aliases already exist
156 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
157 | log_info "ShellCheck aliases already exist in $bashrc"
158 | return 0
159 | fi
160 |
161 | # Add ShellCheck aliases
162 | cat >> "$bashrc" << 'EOF'
163 |
164 | # ShellCheck aliases added by matbrgz dotfiles
165 | alias sccheck='shellcheck'
166 | alias scall='find . -name "*.sh" -type f -exec shellcheck {} \;'
167 | alias scfix='shellcheck --format=diff'
168 | alias scjson='shellcheck --format=json'
169 | EOF
170 |
171 | log_success "ShellCheck aliases added to $bashrc"
172 | }
173 |
174 | verify_installation() {
175 | log_step "Verifying ShellCheck installation"
176 |
177 | if command -v shellcheck >/dev/null 2>&1; then
178 | local version
179 | version=$(shellcheck --version | grep "^version:" | awk '{print $2}')
180 | log_success "ShellCheck version: $version"
181 |
182 | # Test ShellCheck with a simple script
183 | local test_script="/tmp/test_shellcheck.sh"
184 | echo '#!/bin/bash
185 | echo "Hello, World!"' > "$test_script"
186 |
187 | if shellcheck "$test_script" >/dev/null 2>&1; then
188 | log_success "ShellCheck is working correctly"
189 | else
190 | log_warning "ShellCheck test failed"
191 | fi
192 |
193 | rm -f "$test_script"
194 | else
195 | log_error "ShellCheck command not found"
196 | return 1
197 | fi
198 | }
199 |
200 | main() {
201 | log_info "Starting ShellCheck setup"
202 |
203 | install_shellcheck
204 | configure_shellcheck
205 | create_shellcheck_aliases
206 | verify_installation
207 |
208 | log_success "ShellCheck setup completed successfully"
209 |
210 | # Show usage tips
211 | echo
212 | log_info "Usage tips:"
213 | echo " - Check a script: shellcheck script.sh"
214 | echo " - Check all scripts: scall"
215 | echo " - Use 'source ~/.bashrc' to load new aliases"
216 | }
217 |
218 | # Run main function if script is executed directly
219 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
220 | main "$@"
221 | fi
--------------------------------------------------------------------------------
/programs/shfmt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # SHFMT INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install shfmt shell script formatter
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_shfmt() {
19 | log_step "Installing shfmt"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing shfmt installation"
27 | sudo rm -f /usr/local/bin/shfmt /usr/bin/shfmt
28 | fi
29 |
30 | # Try package manager first
31 | case "$pm" in
32 | "apt")
33 | # shfmt is not available in standard apt repos, install from binary
34 | install_shfmt_binary
35 | ;;
36 | "pacman")
37 | sudo pacman -S --noconfirm shfmt 2>/dev/null || install_shfmt_binary
38 | ;;
39 | "yay")
40 | yay -S --noconfirm shfmt 2>/dev/null || install_shfmt_binary
41 | ;;
42 | "dnf")
43 | sudo dnf install -y shfmt 2>/dev/null || install_shfmt_binary
44 | ;;
45 | "zypper")
46 | sudo zypper install -y shfmt 2>/dev/null || install_shfmt_binary
47 | ;;
48 | "snap")
49 | sudo snap install shfmt 2>/dev/null || install_shfmt_binary
50 | ;;
51 | "brew")
52 | brew install shfmt 2>/dev/null || install_shfmt_binary
53 | ;;
54 | *)
55 | install_shfmt_binary
56 | ;;
57 | esac
58 |
59 | log_success "shfmt installed successfully"
60 | }
61 |
62 | install_shfmt_binary() {
63 | log_step "Installing shfmt from binary release"
64 |
65 | local architecture
66 | local os_type
67 | local shfmt_version
68 |
69 | architecture=$(uname -m)
70 | os_type=$(uname -s | tr '[:upper:]' '[:lower:]')
71 |
72 | # Get latest version from GitHub API
73 | shfmt_version=$(curl -s https://api.github.com/repos/mvdan/sh/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')
74 |
75 | if [[ -z "$shfmt_version" ]]; then
76 | log_warning "Could not determine latest shfmt version, using v3.7.0"
77 | shfmt_version="v3.7.0"
78 | fi
79 |
80 | # Map architecture names
81 | case "$architecture" in
82 | "x86_64")
83 | architecture="amd64"
84 | ;;
85 | "i386"|"i686")
86 | architecture="386"
87 | ;;
88 | "aarch64"|"arm64")
89 | architecture="arm64"
90 | ;;
91 | "armv7l")
92 | architecture="arm"
93 | ;;
94 | *)
95 | log_error "Unsupported architecture for binary installation: $architecture"
96 | return 1
97 | ;;
98 | esac
99 |
100 | local download_url="https://github.com/mvdan/sh/releases/download/${shfmt_version}/shfmt_${shfmt_version}_${os_type}_${architecture}"
101 |
102 | log_info "Downloading shfmt ${shfmt_version} for ${os_type}_${architecture}"
103 |
104 | # Download and install
105 | if curl -L "$download_url" -o /tmp/shfmt; then
106 | sudo mv /tmp/shfmt /usr/local/bin/shfmt
107 | sudo chmod +x /usr/local/bin/shfmt
108 |
109 | # Create symlink for convenience
110 | sudo ln -sf /usr/local/bin/shfmt /usr/bin/shfmt 2>/dev/null || true
111 |
112 | log_success "shfmt binary installed to /usr/local/bin/shfmt"
113 | else
114 | log_error "Failed to download shfmt binary"
115 | return 1
116 | fi
117 | }
118 |
119 | configure_shfmt() {
120 | log_step "Configuring shfmt"
121 |
122 | # Create a .editorconfig for shell scripts formatting consistency
123 | local editorconfig="$HOME/.editorconfig"
124 |
125 | if [[ ! -f "$editorconfig" ]]; then
126 | cat > "$editorconfig" << 'EOF'
127 | # EditorConfig configuration for consistent formatting
128 | root = true
129 |
130 | [*]
131 | charset = utf-8
132 | end_of_line = lf
133 | insert_final_newline = true
134 | trim_trailing_whitespace = true
135 |
136 | [*.sh]
137 | indent_style = tab
138 | indent_size = 4
139 |
140 | [*.{yml,yaml,json}]
141 | indent_style = space
142 | indent_size = 2
143 |
144 | [*.md]
145 | trim_trailing_whitespace = false
146 | EOF
147 |
148 | log_success "EditorConfig created at $editorconfig"
149 | else
150 | log_info "EditorConfig already exists"
151 | fi
152 | }
153 |
154 | create_shfmt_aliases() {
155 | log_step "Creating shfmt aliases"
156 |
157 | local bashrc="$HOME/.bashrc"
158 | local aliases_section="# shfmt aliases added by matbrgz dotfiles"
159 |
160 | # Check if aliases already exist
161 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
162 | log_info "shfmt aliases already exist in $bashrc"
163 | return 0
164 | fi
165 |
166 | # Add shfmt aliases
167 | cat >> "$bashrc" << 'EOF'
168 |
169 | # shfmt aliases added by matbrgz dotfiles
170 | alias shfmt-check='shfmt -d'
171 | alias shfmt-fix='shfmt -w'
172 | alias shfmt-all='find . -name "*.sh" -type f -exec shfmt -w {} \;'
173 | alias shfmt-diff='shfmt -d'
174 | EOF
175 |
176 | log_success "shfmt aliases added to $bashrc"
177 | }
178 |
179 | verify_installation() {
180 | log_step "Verifying shfmt installation"
181 |
182 | if command -v shfmt >/dev/null 2>&1; then
183 | local version
184 | version=$(shfmt --version)
185 | log_success "shfmt version: $version"
186 |
187 | # Test shfmt with a simple script
188 | local test_script="/tmp/test_shfmt.sh"
189 | echo '#!/bin/bash
190 | if [ "$1" = "test" ]; then
191 | echo "formatting test"
192 | fi' > "$test_script"
193 |
194 | if shfmt -d "$test_script" >/dev/null 2>&1; then
195 | log_success "shfmt is working correctly"
196 | else
197 | log_warning "shfmt test failed"
198 | fi
199 |
200 | rm -f "$test_script"
201 | else
202 | log_error "shfmt command not found"
203 | return 1
204 | fi
205 | }
206 |
207 | main() {
208 | log_info "Starting shfmt setup"
209 |
210 | install_shfmt
211 | configure_shfmt
212 | create_shfmt_aliases
213 | verify_installation
214 |
215 | log_success "shfmt setup completed successfully"
216 |
217 | # Show usage tips
218 | echo
219 | log_info "Usage tips:"
220 | echo " - Format a script: shfmt -w script.sh"
221 | echo " - Check formatting: shfmt-check script.sh"
222 | echo " - Format all scripts: shfmt-all"
223 | echo " - Use 'source ~/.bashrc' to load new aliases"
224 | }
225 |
226 | # Run main function if script is executed directly
227 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
228 | main "$@"
229 | fi
--------------------------------------------------------------------------------
/programs/spotify.ps1:
--------------------------------------------------------------------------------
1 | cinst -y spotify
--------------------------------------------------------------------------------
/programs/ssh.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # SSH SERVER INSTALLATION SCRIPT
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install and configure OpenSSH server
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | install_ssh() {
19 | log_step "Installing OpenSSH Server"
20 |
21 | local pm
22 | pm=$(detect_package_manager)
23 |
24 | # Check if purge mode is enabled
25 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
26 | log_step "Purging existing SSH installation"
27 | case "$pm" in
28 | "apt")
29 | sudo apt remove -y openssh-server 2>/dev/null || true
30 | sudo apt autoremove -y
31 | ;;
32 | "pacman"|"yay")
33 | sudo pacman -Rs --noconfirm openssh 2>/dev/null || true
34 | ;;
35 | "dnf")
36 | sudo dnf remove -y openssh-server 2>/dev/null || true
37 | ;;
38 | *)
39 | log_warning "Purge not implemented for package manager: $pm"
40 | ;;
41 | esac
42 | fi
43 |
44 | # Install SSH server
45 | case "$pm" in
46 | "apt")
47 | sudo apt update
48 | sudo apt install -y openssh-server
49 | ;;
50 | "pacman")
51 | sudo pacman -S --noconfirm openssh
52 | ;;
53 | "yay")
54 | yay -S --noconfirm openssh
55 | ;;
56 | "dnf")
57 | sudo dnf install -y openssh-server
58 | ;;
59 | "zypper")
60 | sudo zypper install -y openssh
61 | ;;
62 | "brew")
63 | log_warning "SSH server not needed on macOS (built-in)"
64 | return 0
65 | ;;
66 | *)
67 | log_error "Unsupported package manager: $pm"
68 | return 1
69 | ;;
70 | esac
71 |
72 | log_success "OpenSSH Server installed successfully"
73 | }
74 |
75 | configure_ssh() {
76 | log_step "Configuring SSH Server"
77 |
78 | local ssh_config="/etc/ssh/sshd_config"
79 |
80 | # Backup original config
81 | if [[ -f "$ssh_config" ]]; then
82 | sudo cp "$ssh_config" "$ssh_config.backup.$(date +%Y%m%d_%H%M%S)"
83 | log_info "SSH config backed up"
84 | fi
85 |
86 | # Configure SSH with better security
87 | log_step "Applying SSH security configuration"
88 |
89 | # Enable password authentication (can be disabled later for key-only auth)
90 | sudo sed -i 's/#PasswordAuthentication no/PasswordAuthentication yes/' "$ssh_config"
91 | sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' "$ssh_config"
92 |
93 | # Disable root login for security
94 | sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' "$ssh_config"
95 | sudo sed -i 's/PermitRootLogin yes/PermitRootLogin no/' "$ssh_config"
96 |
97 | # Change default port for security (optional)
98 | # sudo sed -i 's/#Port 22/Port 2222/' "$ssh_config"
99 |
100 | # Enable public key authentication
101 | sudo sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' "$ssh_config"
102 |
103 | # Disable X11 forwarding for security
104 | sudo sed -i 's/#X11Forwarding no/X11Forwarding no/' "$ssh_config"
105 | sudo sed -i 's/X11Forwarding yes/X11Forwarding no/' "$ssh_config"
106 |
107 | log_success "SSH configuration applied"
108 | }
109 |
110 | start_ssh_service() {
111 | log_step "Starting SSH service"
112 |
113 | if command -v systemctl >/dev/null 2>&1; then
114 | sudo systemctl enable ssh 2>/dev/null || sudo systemctl enable sshd 2>/dev/null || true
115 | sudo systemctl restart ssh 2>/dev/null || sudo systemctl restart sshd 2>/dev/null || true
116 | log_success "SSH service started and enabled"
117 | else
118 | # Fallback for systems without systemctl
119 | sudo service ssh restart 2>/dev/null || sudo service sshd restart 2>/dev/null || true
120 | log_success "SSH service restarted"
121 | fi
122 | }
123 |
124 | verify_installation() {
125 | log_step "Verifying SSH installation"
126 |
127 | # Check if SSH daemon is running
128 | if systemctl is-active --quiet ssh 2>/dev/null || systemctl is-active --quiet sshd 2>/dev/null; then
129 | log_success "SSH service is running"
130 | else
131 | log_warning "SSH service status unclear"
132 | fi
133 |
134 | # Check SSH port
135 | local ssh_port
136 | ssh_port=$(grep -E "^Port" /etc/ssh/sshd_config 2>/dev/null | awk '{print $2}' || echo "22")
137 | log_info "SSH is configured to run on port: $ssh_port"
138 |
139 | # Show connection info
140 | local hostname
141 | hostname=$(hostname -I 2>/dev/null | awk '{print $1}' || hostname)
142 | log_info "You can connect via: ssh $(whoami)@$hostname"
143 | }
144 |
145 | main() {
146 | log_info "Starting SSH setup"
147 |
148 | install_ssh
149 | configure_ssh
150 | start_ssh_service
151 | verify_installation
152 |
153 | log_success "SSH setup completed successfully"
154 | log_warning "Remember to configure firewall rules if needed"
155 | }
156 |
157 | # Run main function if script is executed directly
158 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
159 | main "$@"
160 | fi
161 |
--------------------------------------------------------------------------------
/programs/station.ps1:
--------------------------------------------------------------------------------
1 | cinst -y station
--------------------------------------------------------------------------------
/programs/steam.ps1:
--------------------------------------------------------------------------------
1 | cinst -y steam
--------------------------------------------------------------------------------
/programs/tools-and-services/chkinstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | dpkg -s $1 &> /dev/null
3 | if [ $? -eq 0 ]; then
4 | printf "\n Package $1 is installed"
5 | else
6 | printf "\n Package $1 was NOT installed!"
7 | fi
--------------------------------------------------------------------------------
/programs/tools-and-services/disable-ads.ps1:
--------------------------------------------------------------------------------
1 | #--- Ad blocking with hosts file ---
2 | $hfile = "$env:windir\System32\drivers\etc\hosts"
3 | function Block-Ad {
4 | Param ($domain)
5 | if (!(Select-String -Path "$hfile" -Pattern "$domain" -SimpleMatch -Quiet)) {
6 | # Doesn't already exist so lets add it
7 | $out = ''
8 | if ($domain -like '* *') {
9 | # add as-is because it's a ip and domain pair
10 | $out = $domain
11 | }
12 | else {
13 | # route to 0.0.0.0
14 | $out = "0.0.0.0 $domain"
15 | }
16 | "$out" | Add-Content -PassThru "$hfile"
17 | Return 0
18 | }
19 | Return -1
20 | }
21 |
22 | Block-Ad 'pubads.g.doubleclick.net'
23 | Block-Ad 'securepubads.g.doubleclick.net'
24 | Block-Ad 'www.googletagservices.com'
25 | Block-Ad 'gads.pubmatic.com'
26 | Block-Ad 'ads.pubmatic.com'
27 | Block-Ad 'spclient.wg.spotify.com'
--------------------------------------------------------------------------------
/programs/tools-and-services/localtunnel-service.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ### BEGIN INIT INFO
4 | # Provides: localtunnel
5 | # Required-Start: $network
6 | # Required-Stop: $network
7 | # Default-Start: 2 3 4 5
8 | # Default-Stop: 0 1 6
9 | # Short-Description: O Meu Serviço
10 | # Description: Uma descricao mais completa sobre o meu serviço
11 | ### END INIT INFO
12 | # chkconfig: 2345 95 20
13 |
14 | loopFunction(bool) {
15 | while true; do
16 | if [ \"${bool}\" == false ]; then
17 | break
18 | fi
19 | lt --port 2200 -s matheusrv;
20 | sleep 10;
21 | done
22 | }
23 |
24 | start() {
25 | loopFunction true
26 | }
27 |
28 | stop() {
29 | loopFunction false
30 | exit 1
31 | }
32 |
33 | restart() {
34 | stop
35 | start
36 | }
37 |
38 | case \"$1\" in
39 | start)
40 | start
41 | ;;
42 | stop)
43 | stop
44 | ;;
45 | restart)
46 | restart
47 | ;;
48 | *)
49 | echo $\"Usage: $0 {start | stop | restart}\"
50 | exit 1
51 | esac
52 |
53 | exit $?
--------------------------------------------------------------------------------
/programs/vlc.ps1:
--------------------------------------------------------------------------------
1 | cinst -y vlc
--------------------------------------------------------------------------------
/programs/vscode.ps1:
--------------------------------------------------------------------------------
1 | cinst -y vscode
2 |
3 | $Extensions = @(
4 | "aaron-bond.better-comments"
5 | "coenraads.bracket-pair-colorizer"
6 | "kamikillerto.vscode-colorize"
7 | "dbaeumer.vscode-eslint"
8 | "davidanson.vscode-markdownlint"
9 | "hookyqr.minify"
10 | "esbenp.prettier-vscode"
11 | "wallabyjs.quokka-vscode"
12 | "ms-vscode-remote.remote-containers"
13 | "ms-vscode-remote.remote-ssh"
14 | "ms-vscode-remote.remote-ssh-edit"
15 | "ms-vscode-remote.remote-ssh-explorer"
16 | "ms-vscode-remote.remote-wsl"
17 | "ms-vscode-remote.vscode-remote-extensionpack"
18 | "ms-vscode-remote.vscode-remote-extensionpack"
19 | "redhat.vscode-yaml"
20 | )
21 |
22 | ForEach ($Extension in $Extensions) {
23 | Write-Output "Instaling $Extension"
24 | code --install-extension $Extension
25 | }
26 |
27 | #code --install-extension EditorConfig.EditorConfig
28 | #code --install-extension vscodevim.vim
29 | #code --install-extension eamodio.gitlens
30 | #code --install-extension gerane.Theme-Paraisodark
31 | #code --install-extension PeterJausovec.vscode-docker
32 | #code --install-extension ms-vscode.PowerShell
33 | #code --install-extension christian-kohler.path-intellisense
34 | #code --install-extension robertohuertasm.vscode-icons
35 | #code --install-extension streetsidesoftware.code-spell-checker
--------------------------------------------------------------------------------
/programs/vscode.sh:
--------------------------------------------------------------------------------
1 | vscode .
--------------------------------------------------------------------------------
/programs/wsl.ps1:
--------------------------------------------------------------------------------
1 | # https://github.com/microsoft/windows-dev-box-setup-scripts/blob/master/scripts/WSL.ps1
2 |
3 | cinst -y Microsoft-Windows-Subsystem-Linux --source="'windowsfeatures'"
4 |
5 | Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu.appx -UseBasicParsing
6 | Add-AppxPackage -Path ~/Ubuntu.appx
7 |
8 | #curl.exe -L -o ubuntu-1804.appx https://aka.ms/wsl-ubuntu-1804
9 | #Add-AppxPackage .\ubuntu-1804.appx
10 | #Rename-Item ./ubuntu-1804.appx ./Ubuntu.zip
11 | #Expand-Archive ./Ubuntu.zip C:\Users\Administrator\Ubuntu
12 | #$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
13 | #[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")
14 |
15 | RefreshEnv
16 |
17 | #if (!(Get-Command 'ubuntu1804' -ErrorAction SilentlyContinue)) {
18 | # Write-Error @'
19 | # You need Windows Subsystem for Linux setup before the rest of this script can run.
20 | # See https://docs.microsoft.com/en-us/windows/wsl/install-win10 for more information.
21 | #'@
22 | # Exit
23 | #}
24 |
25 |
26 | Ubuntu1804 install --root
27 | Ubuntu1804 run apt update
28 | Ubuntu1804 run apt upgrade -y
29 | #$ComputerName = (Get-Culture).TextInfo.ToLower("$ComputerName")
30 |
31 | #if ((wsl awk '/^ID=/' /etc/*-release | wsl awk -F'=' '{ print tolower(\$2) }') -ne 'ubuntu1804') {
32 | # Write-Error 'Ensure Windows Subsystem for Linux is setup to run the Ubuntu distribution'
33 | # Exit
34 | #}
35 |
36 | #if ((wsl awk '/^DISTRIB_RELEASE=/' /etc/*-release | wsl awk -F'=' '{ print tolower(\$2) }') -lt 18.04) {
37 | # Write-Error 'You need to install a minimum of Ubuntu 18.04 Bionic Beaver before running this script'
38 | # Exit
39 | #}
40 |
41 | #Ubuntu1804 run "useradd $ComputerName --disabled-password; echo -e '1234\n1234' | passwd $ComputerName"
42 | #Ubuntu1804 run usermod -aG sudo $ComputerName
43 | #Ubuntu1804 run config --default-user $ComputerName
44 |
45 | Ubuntu1804 run 'git clone https://github.com/MatheusRV/dotfiles && chmod 777 -R dotfiles && cd dotfiles && ./install.sh'
46 |
47 | $Programs = @(
48 | "vcxsrv"
49 | "cmder"
50 | )
51 |
52 | ForEach ($Program in $Programs) {
53 | Write-Output "Instaling $Program"
54 | cinst -y $Program
55 | }
--------------------------------------------------------------------------------
/programs/x11server.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | sudo apt -y install x11-apps
9 | {
10 | # X11 Config
11 | DISPLAY=:0.0
12 | export DISPLAY
13 | } >>"${HOME}"/.bashrc
--------------------------------------------------------------------------------
/programs/yarn-leasot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | yarn global add leasot
--------------------------------------------------------------------------------
/programs/yarn-localtunnel.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | port="$(jq -r '.programs[] | select(.program=="yarn-localtunnel").port' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
9 | hostname="$(jq -r '.programs[] | select(.program=="yarn-localtunnel").hostname' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
10 | yarn global add localtunnel
11 | sudo chmod a+x "${PREVIOUS_PWD}"/programs/tools-and-services/localtunnel-service.sh
12 | sudo cp "${PREVIOUS_PWD}"/programs/tools-and-services/localtunnel-service.sh /etc/init.d/localtunnel
13 | sudo sed -i "/lt --port 2200 -s matheusrv;/c\lt --port ${port} -s ${hostname};" /etc/init.d/localtunnel
14 |
15 | update-rc.d localtunnel defaults
16 |
--------------------------------------------------------------------------------
/programs/yarn-prettier.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # PRETTIER INSTALLATION SCRIPT (via Yarn/NPM)
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Prettier code formatter globally
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | check_dependencies() {
19 | log_step "Checking dependencies"
20 |
21 | # Check if Node.js is installed
22 | if ! command -v node >/dev/null 2>&1; then
23 | log_error "Node.js is required but not installed"
24 | log_info "Please install Node.js first using the nvm.sh or nodejs.sh script"
25 | return 1
26 | fi
27 |
28 | # Prefer yarn over npm if available
29 | local package_manager=""
30 | if command -v yarn >/dev/null 2>&1; then
31 | package_manager="yarn"
32 | log_info "Using Yarn package manager"
33 | elif command -v npm >/dev/null 2>&1; then
34 | package_manager="npm"
35 | log_info "Using NPM package manager"
36 | else
37 | log_error "Neither Yarn nor NPM found"
38 | return 1
39 | fi
40 |
41 | echo "$package_manager"
42 | }
43 |
44 | install_prettier() {
45 | log_step "Installing Prettier"
46 |
47 | local package_manager
48 | package_manager=$(check_dependencies)
49 |
50 | # Check if purge mode is enabled
51 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
52 | log_step "Removing existing Prettier installation"
53 | case "$package_manager" in
54 | "yarn")
55 | yarn global remove prettier 2>/dev/null || true
56 | ;;
57 | "npm")
58 | npm uninstall -g prettier 2>/dev/null || true
59 | ;;
60 | esac
61 | fi
62 |
63 | # Install Prettier globally
64 | case "$package_manager" in
65 | "yarn")
66 | yarn global add prettier
67 | ;;
68 | "npm")
69 | npm install -g prettier
70 | ;;
71 | *)
72 | log_error "Unsupported package manager: $package_manager"
73 | return 1
74 | ;;
75 | esac
76 |
77 | log_success "Prettier installed successfully"
78 | }
79 |
80 | configure_prettier() {
81 | log_step "Configuring Prettier"
82 |
83 | # Create global Prettier configuration
84 | local prettier_config="$HOME/.prettierrc"
85 |
86 | if [[ ! -f "$prettier_config" ]]; then
87 | cat > "$prettier_config" << 'EOF'
88 | {
89 | "semi": true,
90 | "trailingComma": "es5",
91 | "singleQuote": true,
92 | "printWidth": 80,
93 | "tabWidth": 2,
94 | "useTabs": false,
95 | "bracketSpacing": true,
96 | "bracketSameLine": false,
97 | "arrowParens": "avoid",
98 | "endOfLine": "lf",
99 | "quoteProps": "as-needed",
100 | "jsxSingleQuote": true,
101 | "proseWrap": "preserve",
102 | "htmlWhitespaceSensitivity": "css",
103 | "embeddedLanguageFormatting": "auto"
104 | }
105 | EOF
106 |
107 | log_success "Prettier configuration created at $prettier_config"
108 | else
109 | log_info "Prettier configuration already exists"
110 | fi
111 |
112 | # Create .prettierignore file
113 | local prettier_ignore="$HOME/.prettierignore"
114 |
115 | if [[ ! -f "$prettier_ignore" ]]; then
116 | cat > "$prettier_ignore" << 'EOF'
117 | # Dependencies
118 | node_modules/
119 | .pnp
120 | .pnp.js
121 |
122 | # Production builds
123 | build/
124 | dist/
125 | out/
126 |
127 | # Environment variables
128 | .env
129 | .env.local
130 | .env.development.local
131 | .env.test.local
132 | .env.production.local
133 |
134 | # Logs
135 | npm-debug.log*
136 | yarn-debug.log*
137 | yarn-error.log*
138 | lerna-debug.log*
139 |
140 | # Runtime data
141 | pids
142 | *.pid
143 | *.seed
144 | *.pid.lock
145 |
146 | # Coverage directory used by tools like istanbul
147 | coverage/
148 | *.lcov
149 |
150 | # Dependency directories
151 | node_modules/
152 | jspm_packages/
153 |
154 | # Optional npm cache directory
155 | .npm
156 |
157 | # Optional REPL history
158 | .node_repl_history
159 |
160 | # Output of 'npm pack'
161 | *.tgz
162 |
163 | # Yarn Integrity file
164 | .yarn-integrity
165 |
166 | # Stores VSCode versions used for testing VSCode extensions
167 | .vscode-test
168 |
169 | # yarn v2
170 | .yarn/cache
171 | .yarn/unplugged
172 | .yarn/build-state.yml
173 | .yarn/install-state.gz
174 | .pnp.*
175 |
176 | # Generated files
177 | *.min.js
178 | *.min.css
179 | bundle.js
180 | bundle.css
181 |
182 | # Temporary files
183 | *.tmp
184 | *.temp
185 | .cache/
186 |
187 | # OS generated files
188 | .DS_Store
189 | .DS_Store?
190 | ._*
191 | .Spotlight-V100
192 | .Trashes
193 | ehthumbs.db
194 | Thumbs.db
195 |
196 | # IDE files
197 | .idea/
198 | *.swp
199 | *.swo
200 | *~
201 |
202 | # Package files
203 | *.7z
204 | *.dmg
205 | *.gz
206 | *.iso
207 | *.jar
208 | *.rar
209 | *.tar
210 | *.zip
211 | EOF
212 |
213 | log_success "Prettier ignore file created at $prettier_ignore"
214 | else
215 | log_info "Prettier ignore file already exists"
216 | fi
217 | }
218 |
219 | create_prettier_aliases() {
220 | log_step "Creating Prettier aliases"
221 |
222 | local bashrc="$HOME/.bashrc"
223 | local aliases_section="# Prettier aliases added by matbrgz dotfiles"
224 |
225 | # Check if aliases already exist
226 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
227 | log_info "Prettier aliases already exist in $bashrc"
228 | return 0
229 | fi
230 |
231 | # Add Prettier aliases
232 | cat >> "$bashrc" << 'EOF'
233 |
234 | # Prettier aliases added by matbrgz dotfiles
235 | alias prettier-check='prettier --check'
236 | alias prettier-write='prettier --write'
237 | alias prettier-all='prettier --write "**/*.{js,jsx,ts,tsx,json,css,md,html,yml,yaml}"'
238 | alias prettier-js='prettier --write "**/*.{js,jsx,ts,tsx}"'
239 | alias prettier-css='prettier --write "**/*.{css,scss,sass,less}"'
240 | alias prettier-md='prettier --write "**/*.md"'
241 | alias prettier-json='prettier --write "**/*.json"'
242 | alias prettier-config='prettier --write .prettierrc'
243 |
244 | # Prettier project helpers
245 | alias prettier-init='echo "{}" > .prettierrc && echo "node_modules/" > .prettierignore'
246 | alias prettier-check-all='prettier --check "**/*.{js,jsx,ts,tsx,json,css,md,html,yml,yaml}"'
247 | EOF
248 |
249 | log_success "Prettier aliases added to $bashrc"
250 | }
251 |
252 | install_editor_plugins() {
253 | log_step "Installing editor plugins information"
254 |
255 | echo
256 | log_info "Editor plugin installation commands:"
257 | echo
258 | echo "VS Code:"
259 | echo " code --install-extension esbenp.prettier-vscode"
260 | echo
261 | echo "Vim/Neovim:"
262 | echo " :PlugInstall prettier/vim-prettier"
263 | echo
264 | echo "Sublime Text:"
265 | echo " Package Control: Install JsPrettier"
266 | echo
267 | echo "Atom:"
268 | echo " apm install prettier-atom"
269 | echo
270 | echo "WebStorm/IntelliJ:"
271 | echo " Built-in support, enable in Settings > Languages & Frameworks > JavaScript > Prettier"
272 | }
273 |
274 | verify_installation() {
275 | log_step "Verifying Prettier installation"
276 |
277 | if command -v prettier >/dev/null 2>&1; then
278 | local version
279 | version=$(prettier --version)
280 | log_success "Prettier version: $version"
281 |
282 | # Test Prettier with a sample file
283 | local test_file="/tmp/test_prettier.js"
284 | echo 'const hello = "world";console.log(hello)' > "$test_file"
285 |
286 | if prettier --check "$test_file" >/dev/null 2>&1; then
287 | log_success "Prettier is working correctly"
288 | else
289 | log_info "Prettier detected formatting issues (this is normal for the test)"
290 | fi
291 |
292 | rm -f "$test_file"
293 | else
294 | log_error "Prettier command not found"
295 | return 1
296 | fi
297 | }
298 |
299 | show_usage() {
300 | echo
301 | log_info "Prettier usage:"
302 | echo " - Check formatting: prettier-check file.js"
303 | echo " - Format file: prettier-write file.js"
304 | echo " - Format all files: prettier-all"
305 | echo " - Format JS/TS only: prettier-js"
306 | echo " - Format CSS only: prettier-css"
307 | echo " - Format Markdown: prettier-md"
308 | echo " - Check all files: prettier-check-all"
309 | echo
310 | log_info "Project setup:"
311 | echo " - Initialize config: prettier-init"
312 | echo " - Custom config: edit .prettierrc"
313 | echo " - Ignore files: edit .prettierignore"
314 | echo
315 | log_info "Configuration:"
316 | echo " - Global config: $HOME/.prettierrc"
317 | echo " - Global ignore: $HOME/.prettierignore"
318 | echo " - Project config: .prettierrc (overrides global)"
319 | }
320 |
321 | main() {
322 | log_info "Starting Prettier setup"
323 |
324 | install_prettier
325 | configure_prettier
326 | create_prettier_aliases
327 | install_editor_plugins
328 | verify_installation
329 | show_usage
330 |
331 | log_success "Prettier setup completed successfully"
332 | log_info "Use 'source ~/.bashrc' to load new aliases"
333 | }
334 |
335 | # Run main function if script is executed directly
336 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
337 | main "$@"
338 | fi
--------------------------------------------------------------------------------
/programs/yarn-strapi.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # =============================================================================
4 | # STRAPI INSTALLATION SCRIPT (via Yarn/NPM)
5 | # =============================================================================
6 | # Author: matbrgz
7 | # Description: Install Strapi CMS globally via package manager
8 | # =============================================================================
9 |
10 | set -euo pipefail
11 |
12 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
14 |
15 | # Source utilities
16 | source "$PROJECT_ROOT/lib/utils.sh"
17 |
18 | check_dependencies() {
19 | log_step "Checking dependencies"
20 |
21 | # Check if Node.js is installed
22 | if ! command -v node >/dev/null 2>&1; then
23 | log_error "Node.js is required but not installed"
24 | log_info "Please install Node.js first using the nodejs.sh script"
25 | return 1
26 | fi
27 |
28 | # Check Node.js version (Strapi requires Node.js 18.x or higher)
29 | local node_version
30 | node_version=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
31 |
32 | if [[ "$node_version" -lt 18 ]]; then
33 | log_warning "Strapi recommends Node.js 18.x or higher (current: $(node --version))"
34 | log_info "Consider upgrading Node.js for better compatibility"
35 | fi
36 |
37 | # Prefer yarn over npm if available
38 | local package_manager=""
39 | if command -v yarn >/dev/null 2>&1; then
40 | package_manager="yarn"
41 | log_info "Using Yarn package manager"
42 | elif command -v npm >/dev/null 2>&1; then
43 | package_manager="npm"
44 | log_info "Using NPM package manager"
45 | else
46 | log_error "Neither Yarn nor NPM found"
47 | return 1
48 | fi
49 |
50 | echo "$package_manager"
51 | }
52 |
53 | install_strapi() {
54 | log_step "Installing Strapi CLI"
55 |
56 | local package_manager
57 | package_manager=$(check_dependencies)
58 |
59 | # Check if purge mode is enabled
60 | if [[ "$(get_json_value "$PROJECT_ROOT/bootstrap/settings.json" ".system.behavior.purge_mode")" == "true" ]]; then
61 | log_step "Removing existing Strapi installation"
62 | case "$package_manager" in
63 | "yarn")
64 | yarn global remove @strapi/strapi 2>/dev/null || true
65 | yarn global remove strapi 2>/dev/null || true
66 | ;;
67 | "npm")
68 | npm uninstall -g @strapi/strapi 2>/dev/null || true
69 | npm uninstall -g strapi 2>/dev/null || true
70 | ;;
71 | esac
72 | fi
73 |
74 | # Install Strapi CLI
75 | case "$package_manager" in
76 | "yarn")
77 | yarn global add @strapi/strapi
78 | ;;
79 | "npm")
80 | npm install -g @strapi/strapi
81 | ;;
82 | *)
83 | log_error "Unsupported package manager: $package_manager"
84 | return 1
85 | ;;
86 | esac
87 |
88 | log_success "Strapi CLI installed successfully"
89 | }
90 |
91 | create_strapi_aliases() {
92 | log_step "Creating Strapi aliases"
93 |
94 | local bashrc="$HOME/.bashrc"
95 | local aliases_section="# Strapi aliases added by matbrgz dotfiles"
96 |
97 | # Check if aliases already exist
98 | if grep -q "$aliases_section" "$bashrc" 2>/dev/null; then
99 | log_info "Strapi aliases already exist in $bashrc"
100 | return 0
101 | fi
102 |
103 | # Add Strapi aliases
104 | cat >> "$bashrc" << 'EOF'
105 |
106 | # Strapi aliases added by matbrgz dotfiles
107 | alias strapi-new='npx create-strapi-app'
108 | alias strapi-dev='npm run develop'
109 | alias strapi-build='npm run build'
110 | alias strapi-start='npm run start'
111 | EOF
112 |
113 | log_success "Strapi aliases added to $bashrc"
114 | }
115 |
116 | verify_installation() {
117 | log_step "Verifying Strapi installation"
118 |
119 | if command -v strapi >/dev/null 2>&1; then
120 | local version
121 | version=$(strapi version 2>/dev/null || echo "unknown")
122 | log_success "Strapi CLI version: $version"
123 |
124 | # Test if we can use create-strapi-app
125 | if command -v npx >/dev/null 2>&1; then
126 | log_success "npx is available for creating new Strapi projects"
127 | else
128 | log_warning "npx is not available"
129 | fi
130 | else
131 | log_error "Strapi CLI not found"
132 | log_info "Try running 'npx create-strapi-app my-project' to create a new project"
133 | return 1
134 | fi
135 | }
136 |
137 | show_usage() {
138 | echo
139 | log_info "Strapi usage:"
140 | echo " - Create new project: npx create-strapi-app my-project"
141 | echo " - Or use alias: strapi-new my-project"
142 | echo " - Start development: cd my-project && npm run develop"
143 | echo " - Or use alias: strapi-dev"
144 | echo " - Build for production: npm run build"
145 | echo " - Start production: npm run start"
146 | echo
147 | log_info "Strapi admin panel will be available at: http://localhost:1337/admin"
148 | }
149 |
150 | main() {
151 | log_info "Starting Strapi setup"
152 |
153 | install_strapi
154 | create_strapi_aliases
155 | verify_installation
156 | show_usage
157 |
158 | log_success "Strapi setup completed successfully"
159 | log_info "Use 'source ~/.bashrc' to load new aliases"
160 | }
161 |
162 | # Run main function if script is executed directly
163 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
164 | main "$@"
165 | fi
166 |
--------------------------------------------------------------------------------
/remote-install.ps1:
--------------------------------------------------------------------------------
1 | # Set execution policy to remote signed
2 | Set-ExecutionPolicy RemoteSigned
3 |
4 | #TODO: Folder Control (Redirect For a Temp & Check if folder exist)
5 | #TODO: Welcome Message
6 | #TODO: Manage PowerShell install files dynamic
7 |
8 | RefreshEnv
9 | & .\main.ps1
10 |
--------------------------------------------------------------------------------
/remote-install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | {
3 |
4 | : '
5 | printf "\n [ START ] Version Management Control\n"
6 | starttime=$(date +%s)
7 | trap '' 2
8 | if ! git clone https://github.com/molovo/lumberjack; then
9 | echo "Download failed downloading molovo/lumberjack! Exiting."
10 | kill $$
11 | fi
12 | if [ -d /usr/local/bin/lj ]; then
13 | filesha1=find "${PWD}"/lumberjack/lj -type f -print0 | xargs -0 sha1sum | sort | sha1sum
14 | filesha2=find /usr/local/bin/lj -type f -print0 | xargs -0 sha1sum | sort | sha1sum
15 | if [ "$filesha1" != "$filesha2" ]; then
16 | sudo rm -f -R /usr/local/bin/lj
17 | sudo mv lumberjack/lj /usr/local/bin
18 | fi
19 | else
20 | sudo mv lumberjack/lj /usr/local/bin
21 | fi
22 | if ! git clone https://github.com/MatheusRV/dotfiles; then
23 | echo "Download failed downloading matheusrv/dotfiles! Exiting."
24 | kill $$
25 | fi
26 | filesha1=find "${PWD}"/dotfiles -type f -print0 | xargs -0 sha1sum | awk '{print $1}' | sha1sum
27 | exit 1
28 | filesha2=find "${PREVIOUS_PWD}" -type f -print0 | xargs -0 sha1sum | sort | sha1sum
29 | if [ "$filesha1" != "$filesha2" ]; then
30 | if [ -d "${PREVIOUS_PWD}"/programs ]; then
31 | filesha1=find "${PWD}"/dotfiles/programs -type f -print0 | xargs -0 sha1sum | sort | sha1sum
32 | filesha2=find "${PREVIOUS_PWD}"/programs -type f -print0 | xargs -0 sha1sum | sort | sha1sum
33 | if [ "$filesha1" != "$filesha2" ]; then
34 | sudo rm -f -R "${PREVIOUS_PWD}"/programs
35 | sudo mv "${PWD}"/dotfiles/programs "${PREVIOUS_PWD}"/programs
36 | fi
37 | else
38 | sudo mv "${PWD}"/dotfiles/programs "${PREVIOUS_PWD}"/programs
39 | fi
40 | if [ -f "${PREVIOUS_PWD}"/main.sh ]; then
41 | filesha1=sha1sum "${PWD}"/dotfiles/main.sh
42 | filesha2=sha1sum "${PREVIOUS_PWD}"/main.sh
43 | if [ "$filesha1" != "$filesha2" ]; then
44 | sudo rm -f -R "${PREVIOUS_PWD}"/programs
45 | sudo mv "${PWD}"/dotfiles/programs "${PREVIOUS_PWD}"/programs
46 | fi
47 | else
48 | sudo mv "${PWD}"/dotfiles/main.sh "${PREVIOUS_PWD}"
49 | fi
50 | fi
51 | if [ -f "${PREVIOUS_PWD}"/bootstrap/version.json ]; then
52 | filesha1=sha1sum "${PWD}"/bootstrap/version.json
53 | filesha2=sha1sum "${PREVIOUS_PWD}"/bootstrap/version.json
54 | if [ "$filesha1" != "$filesha2" ]; then
55 | sudo rm -f "${PREVIOUS_PWD}"/bootstrap/version.json
56 | chmod +x "${PWD}"/bootstrap/version.json
57 | sudo mv "${PWD}"/bootstrap/version.json "${PREVIOUS_PWD}"/bootstrap
58 | fi
59 | else
60 | chmod +x "${PREVIOUS_PWD}"/bootstrap/version.json
61 | sudo mv "${PWD}"/bootstrap/version.json "${PREVIOUS_PWD}"/bootstrap
62 | fi
63 | if [ -f /usr/local/bin/chkinstall ]; then
64 | filesha1=sha1sum "${PREVIOUS_PWD}"/programs/tools-and-services/chkinstall.sh
65 | filesha2=sha1sum /usr/local/bin/chkinstall
66 | if [ "$filesha1" != "$filesha2" ]; then
67 | sudo rm -f /usr/local/bin/chkinstall
68 | chmod +x "${PREVIOUS_PWD}"/programs/tools-and-services/chkinstall.sh
69 | sudo cp "${PREVIOUS_PWD}"/programs/tools-and-services/chkinstall.sh /usr/local/bin/chkinstall
70 | fi
71 | else
72 | chmod +x "${PREVIOUS_PWD}"/programs/tools-and-services/chkinstall.sh
73 | sudo cp "${PREVIOUS_PWD}"/programs/tools-and-services/chkinstall.sh /usr/local/bin/chkinstall
74 | fi
75 |
76 | lj --file "${PREVIOUS_PWD}"/dotfiles.log --level debug
77 | trap 2
78 | endtime=$(date +%s)
79 | printf " [ DONE ] Version Control ... %s seconds\n" "$((endtime - starttime))"
80 | '
81 | "${PREVIOUS_PWD}"/main.sh "${PREVIOUS_PWD}"
82 | }
83 |
--------------------------------------------------------------------------------
/scaffolding/ex new program:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PREVIOUS_PWD="$1"
3 | if [ "$(jq -r '.configurations.debug' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
4 | set +e
5 | else
6 | set -e
7 | fi
8 | defaultfolder="$(jq -r '.defaultfolder' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)"
9 | # Linux, Dawrin, BSD etc
10 | HEADER_TYPE="$(uname -s)"
11 | # Architeture x86_64 amd64
12 | ARCHITECTURE_TYPE="$(uname -m)"
13 |
14 | # Bionic, Xenial, Trusty
15 | RELEASE_VERSION="$(lsb_release -cs)"
16 | # 18.04
17 | $(lsb_release -rs)
18 | DOCKER_COMPOSE_VERSION="$(jq -r '.DOCKER_COMPOSE_VERSION' "${PREVIOUS_PWD}"/bootstrap/version.json)"/
19 | if [ "$(jq -r '.configurations.purge' "${PREVIOUS_PWD}"/bootstrap/unix-settings.json)" == true ]; then
20 | echo "Anaconda purge not implemented yet! Skipping."
21 | fi
22 |
--------------------------------------------------------------------------------