Skip to content

Commit 9678c93

Browse files
committed
mise en place d'un script pour récupérer et sauvegarder tous les code wifi déjà enregistrés sur un poste
1 parent 4b38b7c commit 9678c93

15 files changed

+673
-358
lines changed

.env.example

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,56 @@
1-
# Configuration locale pour init_mac (NON COMMITÉ)
2-
# Copie ce fichier en .env.local et adapte les chemins
1+
# Local configuration for init_mac (NOT COMMITTED)
2+
# Copy this file to .env.local and adapt the paths
33

4-
# Chemin vers le dossier synchronisé (OneDrive, Synology Drive, Dropbox, etc.)
5-
# Exemples:
4+
# Path to the synchronized folder (OneDrive, Synology Drive, Dropbox, etc.)
5+
# Examples:
66
# SYNC_DIR="$HOME/OneDrive/dotfiles"
77
# SYNC_DIR="$HOME/SynologyDrive/dotfiles"
88
# SYNC_DIR="$HOME/Dropbox/dotfiles"
99
SYNC_DIR=""
1010

11-
# Chemin vers votre fichier packages.conf personnalisé synchronisé (optionnel)
12-
# Si défini, ce fichier sera utilisé au lieu de src/packages.conf.example
13-
# Exemples:
11+
# Path to your custom synchronized packages.conf (optional)
12+
# If set, this file will be used instead of src/packages.conf.example
13+
# Examples:
1414
# PACKAGES_CONF_DIR="$HOME/OneDrive/ok_computer"
1515
# PACKAGES_CONF_DIR="$HOME/SynologyDrive/ok_computer"
1616
PACKAGES_CONF_DIR=""
1717

18-
# Chemin vers le vault Obsidian synchronisé (optionnel)
19-
# Exemples:
18+
# Path to the synchronized Obsidian vault (optional)
19+
# Examples:
2020
# OBSIDIAN_VAULT="$HOME/OneDrive/Obsidian"
2121
# OBSIDIAN_VAULT="$HOME/SynologyDrive/Obsidian"
2222
OBSIDIAN_VAULT=""
2323

24-
# Chemin vers les configurations VS Code synchronisées (optionnel)
25-
# Exemples:
24+
# Path to synchronized VS Code settings (optional)
25+
# Examples:
2626
# VSCODE_CONFIG="$HOME/OneDrive/VSCode"
2727
# VSCODE_CONFIG="$HOME/SynologyDrive/VSCode"
2828
VSCODE_CONFIG=""
2929

30-
# Type de stockage (optionnel, pour logs)
30+
# Storage type (optional, for logs)
3131
# SYNC_TYPE="onedrive"
3232
SYNC_TYPE=""
3333

34-
# Activer la synchronisation des dotfiles (true/false)
34+
# Enable dotfiles synchronization (true/false)
3535
ENABLE_DOTFILES_SYNC=false
3636

37-
# Wi-Fi depuis KeePassXC (optionnel)
38-
# Exemple: WIFI_KDBX_DB="$HOME/OneDrive/vaults/wifi.kdbx"
39-
# Optionnel: WIFI_KDBX_GROUP="Wi-Fi" (nom du groupe dans le vault)
40-
# Optionnel: WIFI_KDBX_KEY_FILE="/chemin/vers/clef.key" (si vault protégé par keyfile)
41-
# Optionnel: WIFI_KDBX_DRY_RUN=1 pour simuler sans appliquer
42-
# Optionnel: WIFI_KDBX_ASK_PASS=1 pour forcer la saisie interactive du mot de passe (aucun secret dans l'env)
37+
# Wi-Fi from KeePassXC (optional)
38+
# Example: WIFI_KDBX_DB="$HOME/OneDrive/vaults/wifi.kdbx"
39+
# Optional: WIFI_KDBX_GROUP="Wi-Fi" (group name in the vault)
40+
# Optional: WIFI_KDBX_KEY_FILE="/path/to/keyfile" (if vault uses a keyfile)
41+
# Optional: WIFI_KDBX_DRY_RUN=1 to simulate without applying
42+
# Optional: WIFI_KDBX_ASK_PASS=1 to force interactive password prompt (do not store secrets in env)
4343
WIFI_KDBX_DB=""
44-
WIFI_KDBX_GROUP="Wi-Fi"
44+
WIFI_KDBX_GROUP="Wifi"
4545
WIFI_KDBX_KEY_FILE=""
4646
WIFI_KDBX_DRY_RUN=0
47-
WIFI_KDBX_ASK_PASS=0
47+
WIFI_KDBX_ASK_PASS=1
48+
49+
# Automatic update schedule (24-hour)
50+
# AUTO_UPDATE_HOUR: hour in 0-23 (default 21)
51+
# AUTO_UPDATE_MINUTE: minute in 0-59 (default 0)
52+
# Example: AUTO_UPDATE_HOUR=21
53+
# AUTO_UPDATE_MINUTE=30
54+
AUTO_UPDATE_HOUR=21
55+
AUTO_UPDATE_MINUTE=0
4856

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Configuration locale
1+
# Local configuration
22
.env.local
33
src/packages.conf
44

README.md

Lines changed: 144 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,155 @@
11
# ok_computer
2+
# ok_computer
23

3-
Simple repo pour ré-installer plus vite un ordinateur neuf (macOS, Windows, Linux).
4+
Repository to quickly reconfigure a new computer (macOS, Windows, Linux).
45

5-
## Installation rapide
6+
## Quick Install
67

7-
### Via les releases (recommandé)
8+
### From releases (recommended)
89

9-
Télécharger la dernière release :
10+
Download the latest release and extract:
1011
```bash
1112
curl -fsSL -o init-computer.tar.gz \
1213
https://github.com/axgd-code/ok_computer/releases/download/$(curl -s https://api.github.com/repos/axgd-code/ok_computer/releases/latest | grep tag_name | cut -d'"' -f4)/init-mac-scripts.tar.gz
1314
tar -xzf init-computer.tar.gz
14-
bash init.sh
1515
```
1616

17-
Ou télécharger manuellement depuis [releases](https://github.com/axgd-code/ok_computer/releases), puis :
17+
Run the installer using the `okc` helper included in the archive:
18+
```bash
19+
chmod +x okc
20+
./okc init
21+
```
22+
23+
If you prefer, install `okc` system-wide first and then run:
1824
```bash
19-
tar -xzf init-mac-scripts.tar.gz
20-
bash init.sh
25+
chmod +x okc install_okc.sh
26+
./install_okc.sh # or sudo ./install_okc.sh
27+
okc init
2128
```
2229

23-
### Depuis le code source
30+
### From source
2431

25-
Cloner et exécuter depuis les sources :
2632
```bash
2733
git clone https://github.com/axgd-code/ok_computer.git
2834
cd ok_computer
29-
bash src/init.sh
35+
chmod +x okc install_okc.sh
36+
./install_okc.sh # optional: install okc into your PATH
37+
okc init
3038
```
3139

3240
## Structure
3341

34-
- [src](src) : scripts et configuration principale
35-
- [src/init.sh](src/init.sh) : orchestrateur qui détecte l'OS et déclenche l'installation
36-
- [src/init_conf_macOs.sh](src/init_conf_macOs.sh) / [src/init_conf_windows.sh](src/init_conf_windows.sh) : réglages spécifiques macOS ou Windows
37-
- [src/packages.conf](src/packages.conf) : catalogue des packages installés
38-
- [src/app.sh](src/app.sh) : gestionnaire d'applications (ajout/suppression/list)
39-
- [src/dotfiles.sh](src/dotfiles.sh) : gestion et synchro des dotfiles
40-
- [src/wifi_from_kdbx.sh](src/wifi_from_kdbx.sh) : import Wi-Fi depuis KeePassXC
41-
- [src/install_fonts.sh](src/install_fonts.sh), [src/setup_auto_update.sh](src/setup_auto_update.sh), [src/update.sh](src/update.sh)
42-
- [test](test) : vérifications locales
43-
- [test/test.sh](test/test.sh) : `bash -n` + `shellcheck` (si présent)
44-
45-
## Fichiers du projet
46-
47-
### 📋 Configuration
48-
- [src/packages.conf](src/packages.conf) : fichier de configuration unifié listant tous les packages à installer pour macOS et Windows
49-
- Format : `TYPE|NOM_MAC|NOM_WINDOWS|DESCRIPTION`
50-
- Les packages s'installent automatiquement lors de l'exécution de [src/init.sh](src/init.sh)
51-
52-
### 🔧 Scripts d'installation
53-
- [src/init.sh](src/init.sh) : script principal qui détecte le système d'exploitation et lance la configuration appropriée
54-
- [src/init_conf_macOs.sh](src/init_conf_macOs.sh) : configuration spécifique à macOS (préférences système, Dock, Finder, etc.)
55-
- [src/init_conf_windows.sh](src/init_conf_windows.sh) : installation des packages via Chocolatey pour Windows
56-
- [src/install_fonts.sh](src/install_fonts.sh) : installation des polices de caractères (macOS)
57-
- [src/app.sh](src/app.sh) : gestionnaire d'applications simple pour installer/désinstaller des apps et mettre à jour [src/packages.conf](src/packages.conf)
58-
- [src/dotfiles.sh](src/dotfiles.sh) : gestionnaire des dotfiles synchronisés via OneDrive, Synology Drive, etc.
59-
- [src/wifi_from_kdbx.sh](src/wifi_from_kdbx.sh) : import de profils Wi-Fi depuis un vault KeePassXC
60-
61-
### 🔄 Mise à jour automatique
62-
- [src/update.sh](src/update.sh) : script de mise à jour des packages
63-
- Exécutable manuellement : `bash src/update.sh`
64-
- Met à jour automatiquement tous les packages selon le système :
65-
- macOS : Homebrew, casks
66-
- Windows : Chocolatey
67-
- Linux : apt/dnf/yum
68-
69-
- [src/setup_auto_update.sh](src/setup_auto_update.sh) : configure la mise à jour automatique quotidienne à 21h00
70-
- Utilise launchd sur macOS
71-
- Utilise Task Scheduler sur Windows
72-
- Utilise cron sur Linux
73-
- Commande : `bash src/setup_auto_update.sh`
74-
75-
## Systèmes supportés
76-
77-
### 🍎 macOS
78-
- Installation via Homebrew
79-
- Configuration automatique des préférences système
80-
- Installation de polices personnalisées
81-
- Mise à jour automatique des packages
82-
83-
### 🪟 Windows
84-
- Installation via Chocolatey (installation automatique si absent)
85-
- Support de Git Bash, WSL, CYGWIN et MINGW
86-
- Mise à jour automatique via Task Scheduler
87-
88-
### 🐧 Linux
89-
- Détection automatique du gestionnaire de packages (apt, dnf, yum)
90-
- Mise à jour automatique via cron
91-
92-
## Packages inclus
93-
94-
Les packages installés incluent :
95-
- Outils de développement : Git, Node.js, Docker, VS Code, OpenJDK, etc.
96-
- Navigateurs : Firefox, Tor Browser
97-
- Communication : Thunderbird, Signal
98-
- Sécurité : KeePassXC, Cryptomator, VeraCrypt
99-
- Productivité : Notion, Obsidian, Postman, Bruno
100-
- Multimédia : VLC, FFmpeg
101-
- Utilitaires : 7-Zip, TeamViewer, Transmission
102-
- Et bien d'autres...
103-
104-
## Configuration de la mise à jour automatique
105-
106-
Pour activer la mise à jour automatique quotidienne à 21h00 :
42+
- `src/`: main scripts and configuration
43+
- `src/init.sh`: orchestrator that detects OS and runs setup
44+
- `src/init_conf_macOs.sh` / `src/init_conf_windows.sh`: platform-specific configuration
45+
- `src/packages.conf`: list of packages to install
46+
- `src/app.sh`: simple app manager (add/remove/list)
47+
- `src/dotfiles.sh`: dotfiles sync manager
48+
- `src/wifi_from_kdbx.sh`: import Wi‑Fi profiles from KeePassXC
49+
- `src/update.sh`: update script for packages
50+
- `src/setup_auto_update.sh`: configure automatic daily updates
51+
- `test/`: local checks
52+
53+
## Configuration
54+
55+
Copy `.env.example` to `.env.local` and edit to match your paths.
56+
Typical variables:
57+
- `SYNC_DIR` — path to your synchronized folder (OneDrive, Synology Drive, Dropbox, ...)
58+
- `PACKAGES_CONF_DIR` — optional remote folder to store a shared `packages.conf`
59+
- `OBSIDIAN_VAULT`, `VSCODE_CONFIG` — optional sync targets
60+
61+
Automatic update schedule (optional):
62+
- `AUTO_UPDATE_HOUR` — hour in 0-23 (default: 21)
63+
- `AUTO_UPDATE_MINUTE` — minute in 0-59 (default: 0)
64+
65+
Example `.env.local` additions:
66+
```dotenv
67+
AUTO_UPDATE_HOUR=21
68+
AUTO_UPDATE_MINUTE=0
69+
```
70+
71+
`src/setup_auto_update.sh` reads `.env.local` (one level up) and uses these values to configure:
72+
- macOS: a `launchd` agent (`$HOME/Library/LaunchAgents/...plist`)
73+
- Windows: a scheduled task via `schtasks` (uses the provided time)
74+
- Linux: a cron job (uses the provided minute/hour)
75+
76+
## Commands using `okc`
77+
78+
Use `okc` to run repository scripts without typing `bash src/...`.
79+
80+
Dotfiles examples:
10781
```bash
108-
bash src/setup_auto_update.sh
82+
okc dotfiles init # initialize sync
83+
okc dotfiles setup # create symlinks
84+
okc dotfiles sync # push changes to sync folder
85+
okc dotfiles restore # restore from sync folder
86+
okc dotfiles status # show status
10987
```
11088

111-
### Commandes de gestion
89+
App manager examples:
90+
```bash
91+
okc app install firefox
92+
okc app uninstall firefox
93+
okc app list
94+
okc app add some-app
95+
okc app remove some-app
96+
```
11297

113-
**macOS** :
98+
Automatic updates setup:
11499
```bash
115-
# Désactiver
116-
launchctl unload ~/Library/LaunchAgents/com.user.packages.update.plist
100+
okc setup_auto_update
101+
```
117102

118-
# Réactiver
119-
launchctl load ~/Library/LaunchAgents/com.user.packages.update.plist
103+
If you prefer to run the script directly:
104+
```bash
105+
bash src/setup_auto_update.sh
120106
```
121107

122-
**Windows** :
123-
```cmd
124-
# Désactiver
125-
schtasks //Change //TN "PackagesAutoUpdate" //DISABLE
108+
## Wi‑Fi import from KeePassXC
126109

127-
# Réactiver
128-
schtasks //Change //TN "PackagesAutoUpdate" //ENABLE
110+
Use `okc` or run the script directly:
111+
```bash
112+
okc wifi_from_kdbx --db /path/to/vault.kdbx --group "Wi-Fi"
113+
# or
114+
bash src/wifi_from_kdbx.sh --db /path/to/vault.kdbx --group "Wi-Fi"
115+
```
116+
117+
## Tests
129118

130-
# Supprimer
131-
schtasks //Delete //TN "PackagesAutoUpdate" //F
119+
Run local checks:
120+
```bash
121+
bash test/test.sh
132122
```
133123

134-
**Linux** :
124+
## okc — quick helper
125+
126+
The `okc` script dispatches to `src/<command>.sh` so you can run tasks like `okc init`, `okc app`, `okc dotfiles`.
127+
128+
Install example (local):
135129
```bash
136-
# Voir les tâches cron
137-
crontab -l
130+
chmod +x okc
131+
./okc init
132+
```
138133

139-
# Éditer les tâches cron
140-
crontab -e
134+
Install example (system):
135+
```bash
136+
chmod +x okc install_okc.sh
137+
sudo ./install_okc.sh
138+
okc init
141139
```
142140

143-
## Logs
141+
## License
144142

145-
Les logs de mise à jour sont sauvegardés dans :
146-
- `update.log` : sortie standard
147-
- `update_error.log` : erreurs (macOS uniquement)
143+
See [LICENSE](LICENSE)
148144

149-
## Ajouter ou modifier des packages
145+
Run local checks:
146+
```bash
147+
bash test/test.sh
148+
```
150149

150+
## License
151+
152+
See [LICENSE](LICENSE)
151153
### Configuration personnalisée (recommandé)
152154

153155
Pour avoir votre propre liste de packages synchronisée entre vos machines :
@@ -456,3 +458,36 @@ GitHub Actions crée la release automatiquement.
456458
## License
457459

458460
Voir le fichier [LICENSE](LICENSE)
461+
462+
## okc — utilitaire rapide
463+
464+
Le script `okc` permet d'appeler rapidement les scripts présents dans `src/` sans préfixer par `bash src/...`.
465+
466+
Exemples :
467+
468+
```bash
469+
okc init # lance src/init.sh
470+
okc app install firefox # lance src/app.sh install firefox
471+
okc dotfiles sync # lance src/dotfiles.sh sync
472+
okc packages sync # alias géré via src/dotfiles.sh packages
473+
```
474+
475+
Installation recommandée (copie/symlink dans votre PATH) :
476+
477+
```bash
478+
chmod +x okc install_okc.sh
479+
./install_okc.sh
480+
# ou (installation système)
481+
sudo ./install_okc.sh
482+
```
483+
484+
Le script `install_okc.sh` installe `okc` dans `/usr/local/bin` si possible, sinon dans `~/.local/bin` et ajoute `~/.local/bin` à `~/.profile` si nécessaire.
485+
486+
Vous pouvez aussi installer manuellement :
487+
488+
```bash
489+
chmod +x okc
490+
sudo ln -sf "$PWD/okc" /usr/local/bin/okc
491+
```
492+
493+
Après installation, exécutez `okc` depuis n'importe où.

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ for script in "${SRC_DIR}"/*.sh; do
4848
echo "Compilé: ${script}${DIST_DIR}/$(basename "${script}")"
4949
done
5050

51-
# Inclure le fichier de configuration pour distribution
51+
# Include configuration file for distribution
5252
if [ -f "${SRC_DIR}/packages.conf" ]; then
5353
cp "${SRC_DIR}/packages.conf" "${DIST_DIR}/packages.conf"
5454
fi

0 commit comments

Comments
 (0)