This repository was archived by the owner on Feb 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsetup-updates.sh
More file actions
executable file
·138 lines (115 loc) · 4.3 KB
/
setup-updates.sh
File metadata and controls
executable file
·138 lines (115 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# Script di configurazione per Tempo Update System
# Questo script ti guiderà attraverso la configurazione degli aggiornamenti automatici
echo "🍅 Tempo - Configurazione Sistema Aggiornamenti"
echo "=================================================="
echo ""
# Funzione per richiedere input
read_input() {
local prompt="$1"
local variable_name="$2"
local default_value="$3"
if [ -n "$default_value" ]; then
read -p "$prompt [$default_value]: " input
if [ -z "$input" ]; then
input="$default_value"
fi
else
read -p "$prompt: " input
fi
eval "$variable_name='$input'"
}
# Raccolta informazioni
echo "1. Configurazione Repository GitHub"
echo "-----------------------------------"
read_input "Username GitHub" github_username
read_input "Nome Repository" github_repo "tempo"
echo ""
echo "2. Configurazione Chiavi"
echo "------------------------"
read_input "Nome file chiave" key_name "tempo_signing_key"
# Creazione della directory per le chiavi
key_dir="$HOME/.tauri"
mkdir -p "$key_dir"
echo ""
echo "📝 Generazione chiavi di firma..."
# Controlla se tauri CLI è disponibile
if ! command -v tauri &> /dev/null; then
echo "❌ Tauri CLI non trovato. Installandolo..."
npm install --save-dev @tauri-apps/cli@latest
if ! command -v npx &> /dev/null; then
echo "❌ NPM non trovato. Installa Node.js prima di continuare."
exit 1
fi
# Usa npx se tauri non è nel PATH
TAURI_CMD="npx tauri"
else
TAURI_CMD="tauri"
fi
# Genera le chiavi
echo "🔑 Generazione keypair..."
$TAURI_CMD signer generate -w "$key_dir/$key_name"
if [ $? -eq 0 ]; then
echo "✅ Chiavi generate con successo!"
# Ottieni la chiave pubblica
echo ""
echo "🔑 La tua chiave pubblica è:"
echo "----------------------------------------"
public_key=$($TAURI_CMD signer sign -k "$key_dir/$key_name" --password "" 2>/dev/null | head -1)
echo "$public_key"
echo "----------------------------------------"
# Aggiorna tauri.conf.json
echo ""
echo "📝 Aggiornamento configurazione..."
# Sostituisce i placeholder nel file di configurazione
config_file="src-tauri/tauri.conf.json"
if [ -f "$config_file" ]; then
# Backup del file originale
cp "$config_file" "$config_file.backup"
# Sostituzioni
sed -i.tmp "s/{{OWNER}}/$github_username/g" "$config_file"
sed -i.tmp "s/{{REPO}}/$github_repo/g" "$config_file"
sed -i.tmp "s/YOUR_PUBLIC_KEY_HERE/$public_key/g" "$config_file"
rm "$config_file.tmp" 2>/dev/null
echo "✅ Configurazione aggiornata!"
else
echo "⚠️ File $config_file non trovato"
fi
# Aggiorna il main.js con i link del repository
main_js_file="src/main.js"
if [ -f "$main_js_file" ]; then
sed -i.tmp "s/YOUR_USERNAME/$github_username/g" "$main_js_file"
sed -i.tmp "s/YOUR_REPO/$github_repo/g" "$main_js_file"
rm "$main_js_file.tmp" 2>/dev/null
echo "✅ Link repository aggiornati!"
fi
# Aggiorna l'update manager
update_manager_file="src/managers/update-manager.js"
if [ -f "$update_manager_file" ]; then
sed -i.tmp "s/USERNAME\/REPOSITORY/$github_username\/$github_repo/g" "$update_manager_file"
rm "$update_manager_file.tmp" 2>/dev/null
echo "✅ Update manager configurato!"
fi
echo ""
echo "🎉 Configurazione completata!"
echo ""
echo "📋 Prossimi passi:"
echo "1. Aggiungi questi secrets al tuo repository GitHub:"
echo " - TAURI_SIGNING_PRIVATE_KEY: (contenuto di $key_dir/$key_name)"
echo " - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: (lascia vuoto se non hai impostato una password)"
echo ""
echo "2. Per ottenere la chiave privata:"
echo " cat $key_dir/$key_name"
echo ""
echo "3. Crea una release su GitHub per testare gli aggiornamenti:"
echo " git tag v0.2.0"
echo " git push origin v0.2.0"
echo ""
echo "4. L'app controllerà automaticamente gli aggiornamenti all'avvio"
echo ""
echo "⚠️ IMPORTANTE: Non committare mai la chiave privata nel repository!"
echo " La chiave è salvata in: $key_dir/$key_name"
else
echo "❌ Errore nella generazione delle chiavi"
exit 1
fi