-
Notifications
You must be signed in to change notification settings - Fork 0
/
aursetup.sh
78 lines (61 loc) · 1.55 KB
/
aursetup.sh
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
#!/bin/bash
optbox=( --colors --no-shadow --no-collapse )
dialog "${optbox[@]}" --infobox "
\Z1AUR\Z0
Git Setup
" 9 58
sleep 2
if [[ -e /home/alarm/.ssh/aur ]]; then
dialog "${optbox[@]}" --yesno "
AUR Git has already setup.
\Z1Continue?\Z0
" 0 0
[[ $? == 1 ]] && exit
fi
echo "
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur
" >> /etc/ssh/ssh_config
systemctl restart sshd
[[ -e /usr/bin/git ]] || pacman -Sy --noconfirm git
keys=$( dialog "${optbox[@]}" --output-fd 1 --nocancel --menu "
\Z1Raspberry Pi:\Z0
" 8 0 0 \
1 'Use existing keys' \
2 'Generate new keys' )
dirssh=/home/alarm/.ssh
if [[ $keys == 1 ]]; then
dialog "${optbox[@]}" --msgbox "
Copy saved \Z1.ssh/{aur,aur.pub}\Z0 > /home/alarm
Then press OK to continue.
" 7 58
else
ssh-keygen -t rsa -f ~/.ssh/aur -q -N ""
sed -i 's/= .*$/=/' ~/.ssh/aur.pub # remove trailing USER@HOSTNAME
mkdir -p $dirssh
cp -r ~/.ssh/aur* $dirssh
dialog "${optbox[@]}" --msgbox "
AUR > My Account
\Z1SSH Public Key:\Z0
$( cat $dirssh/aur.pub )
\Z1PGP Key Fingerprint:\Z0 (empty)
\Z1Your current password:\Z0 (password)
" 24 58
fi
chown -R alarm:alarm $dirssh
chmod 700 $dirssh
chmod 600 $dirssh/*
email=$( dialog "${optbox[@]}" --output-fd 1 --inputbox "
\Z1Email:\Z0
" 0 0 [email protected] )
username=$( dialog "${optbox[@]}" --output-fd 1 --inputbox "
\Z1Username:\Z0
" 0 0 rern )
echo "\
[user]
email = [email protected]
name = rern
" > /home/alarm/.gitconfig
chown -R alarm:alarm /home/alarm/.gitconfig $dirssh
sudo -u alarm git init /home/alarm