-
Notifications
You must be signed in to change notification settings - Fork 1
/
archcfg-mod-dev.sh
executable file
·326 lines (290 loc) · 7.5 KB
/
archcfg-mod-dev.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#!/bin/bash
#arch linux configuration script
#This script is intended for inexperienced Arch Linux users and can aid with the request about system files.
#Furthermore the script can give information about hardware.
#
#goranvxiii@gmail.com
VER='X.X.X'
#who are you
if [[ $UID -eq 0 ]]; then
if [[ $USER == "root" ]]; then
dialog --msgbox "Run me whit 'su -c'" 5 24
fi
dialog --infobox "***Loading***" 3 17
else
dialog --msgbox "***Read-only mode***" 5 24
dialog --infobox "***Loading***" 3 17
fi
#set editor
[[ ! $EDITOR ]] && EDITOR=nano
#count new package
_numpkg=0
for a in $( `echo pacman -Qqu` ); do
(( _numpkg++ ))
done
#set temp files
_temp="/tmp/answer.$$"
PN=`basename "$0"`
dialog 2>$_temp
DVER=`cat $_temp | head -1`
# Cleanup temporary file in case of keyboard interrupt or termination signal.
function cleanup_temp {
[ -e $_temp ] && rm --force $_temp
exit 0
}
trap cleanup_temp SIGHUP SIGINT SIGPIPE SIGTERM
#############################################################################################################
#edit xinitrc
xinitrc() {
filename="/home/$USER"
if [ -d $filename ]; then
$EDITOR /home/$USER/.xinitrc
else
dialog --msgbox "*** ERROR ***\n$filename does not exist" 6 80
fi
return
}
#edit rc.conf
/etc/rc.conf() {
$EDITOR /etc/rc.conf #$R
return
}
#edit modprobe
/etc/modprobe() {
$EDITOR /etc/modprobe.d/modprobe.conf
return
}
#edit pacman.conf
/etc/pacman.conf() {
$EDITOR /etc/pacman.conf #$P
return
}
#edit mirrorliste
/etc/pacman.d/mirrorlist() {
$EDITOR /etc/pacman.d/mirrorlist #$M
return
}
#edit xorg.conf.d
/etc/X11/xorg.conf.d() {
echo "Files in /etc/X11/xorg.conf.d/" && echo
ls -l /etc/X11/xorg.conf.d/ | grep ^- | awk '{print $9}'
echo && echo "ENTER NAME OF FILE OR PRESS ENTER TO EXIT:" && read ans
if [[ -z $ans ]]; then
return
else
$EDITOR /etc/X11/xorg.conf.d/$ans #$X
fi
return
}
#edit smb.conf
/etc/samba/smb.conf() {
$EDITOR /etc/samba/smb.conf #$S
return
}
#edit inittab
/etc/inittab() {
$EDITOR /etc/inittab #$I
return
}
#edit grub menu.lst
/boot/grub/menu.lst() {
$EDITOR /boot/grub/menu.lst #$O
return
}
#edit grub2 grub.cfg
/boot/grub/grub.cfg() {
$EDITOR /boot/grub/grub.cfg #$G
return
}
#edit fstab
/etc/fstab() {
$EDITOR /etc/fstab #$F
return
}
#cpufreq
CPUFREQ() {
$EDITOR /etc/conf.d/cpufreq #$CPUFREQ
return
}
#edit mkinitcpio.conf
/etc/mkinitcpio.conf() {
$EDITOR /etc/mkinitcpio.conf #$H
return
}
#Rebuild kernel
anykernel() {
if [[ $UID -ne 0 ]]; then
dialog --msgbox "Need the rights of root! Log in as root and try again." 6 60
return
fi
echo "ENTER SHORT NAME OF KERNEL (-lts -ck -bfs...) OR PRESS ENTER FOR DEFAULT:" && read kerver
filename="/etc/mkinitcpio.d/linux$kerver.preset"
if [ -e $filename ]; then
mkinitcpio -p linux$kerver && echo && echo --- Finished --- && read
else
dialog --msgbox "*** ERROR ***\n'linux$kerver' does not exist" 6 80
fi
return
}
#Sytemupdate
update() {
if [[ $UID -ne 0 ]]; then
dialog --msgbox "Need the rights of root! Log in as root and try again." 6 60
return
fi
pacman -Syu && echo && echo --- Finished --- && read
return
}
#allsysupdate
allupdate() {
filename="/usr/bin/yaourt"
if [ -e $filename ]; then
yaourt -Syua && echo && echo --- Finished --- && read
else
dialog --msgbox "*** ERROR ***\n'$filename' does not exist" 6 80
fi
return
}
#pacman log
/var/log/pacman() {
$EDITOR /var/log/pacman.log #$F
return
}
#pacman log
/var/log/Xorg() {
$EDITOR /var/log/Xorg.0.log #$F
return
}
#read any log
/var/log() {
echo "Files in /var/log/" && echo
ls -l /var/log/ | grep ^- | awk '{print $9}'
echo && echo "ENTER NAME OF FILE OR PRESS ENTER TO EXIT:" && read ans
filename="/var/log/$ans"
if [[ -z $ans ]]; then
return
elif [ -e $filename ]; then
$EDITOR /var/log/$ans #$X
else
echo && echo "FILE '$ans' DOES NOT EXIST!" && echo
/var/log
fi
return
}
#cfdisk
cfdisk() {
if [[ $UID -ne 0 ]]; then
dialog --msgbox "Need the rights of root! Log in as root and try again." 6 60
return
fi
exe='cfdisk' && exec $exe #$CFDISK
return
}
#cpuinfo
CPUINFO() {
dialog --msgbox "`cat /proc/cpuinfo`" 60 150
return
}
#memory
MEMORY() {
dialog --msgbox "`free`" 25 80
return
}
#hard disc allocation
HDD() {
dialog --msgbox "`df -h`" 20 80
return
}
#hardware temperature
TEMP() {
dialog --msgbox "`sensors`" 15 70
return
}
#Release information
Versionshinweise() {
touch /tmp/ver.txt
echo "This script is only for Arch Linux users. Use at one's own risk!" >/tmp/ver.txt
echo "Version $VER" >> /tmp/ver.txt
filename="/tmp/ver.txt"
if [ -e $filename ]; then
dialog --backtitle "Release information"\
--begin 3 5 --title " viewing File: $filename "\
--textbox $filename 20 100
rm $filename
else
dialog --msgbox "*** ERROR ***\n$filename does not exist" 6 80
fi
}
#############################################################################################################
main_menu() {
dialog --title "Arch Linux system configuration script. ver $VER." \
--menu "You are '$USER'. Editor is '$EDITOR'. New packages '$_numpkg'." 40 150 35 \
-configuration ""\
XINITRC "/home/$USER/.xinitrc ------------- File read by xinit and startx"\
RC.CONF "/etc/rc.conf --------------------- Main Configuration file"\
MODPROBE "/etc/modporbe.d/modprobe.conf---- Pass module settings to udev"\
PACMAN.CONF "/etc/pacman.conf ----------------- Configuration file for Pacman"\
MIRRORS "/etc/pacman.d/mirrorlist --------- Pacman's serverlist"\
X11 "/etc/X11/xorg.conf.d/$ ----------- Configuration file's for X11"\
INIT "/etc/inittab --------------------- Configuration file for init systems"\
SAMBA "/etc/samba/smb.conf -------------- Configuration file for samba"\
OLDGRUB "/boot/grub/menu.lst -------------- GRUB configuration file for booting"\
GRUB2 "/boot/grub/grub.cfg -------------- GRUB2 configuration file for booting"\
CPUFREQ "/etc/conf.d/cpufreq--------------- Configuration file for Cpufreq-Utils"\
FSTAB "/etc/fstab ----------------------- Configuration file for partitions on HDD"\
HOOKS "/etc/mkinitcpio.conf ------------- Configuration file for rebuilding the kernel"\
-log ""\
LOG_PACMAN "Pacman log ----------------------- Read pacman log"\
LOG_XORG "Xorg log ------------------------- Read xorg log"\
LOG "Any log -------------------------- Read any log"\
-commands ""\
ANY_KERNEL "Mkinitcpio -p linux$ ------------- Rebuild any kernel"\
PACMAN "Pacman -Syu ---------------------- Complete system update"\
YAOURT "Yaourt -Syua --------------------- Complete system and AUR update"\
-programs ""\
CFDISK "Cfdisk --------------------------- Partition manager"\
-sundry ""\
CPUINFO "Show processor information"\
MEMORY "Show main memory capacity utilisation"\
HDD "Show hard disc allocation "\
TEMP "Show hardware temperature"\
VERSION "Release information" 2>$_temp
opt=${?}
if [ $opt != 0 ]; then
rm $_temp
exit
fi
menuitem=`cat $_temp`
case $menuitem in
XINITRC) xinitrc;;
RC.CONF) /etc/rc.conf;;
MODPROBE) /etc/modprobe;;
CPUFREQ) CPUFREQ;;
INIT) /etc/inittab;;
SAMBA) /etc/samba/smb.conf;;
PACMAN.CONF) /etc/pacman.conf;;
MIRRORS) /etc/pacman.d/mirrorlist;;
HOOKS) /etc/mkinitcpio.conf;;
X11) /etc/X11/xorg.conf.d;;
OLDGRUB) /boot/grub/menu.lst;;
GRUB2) /boot/grub/grub.cfg;;
FSTAB) /etc/fstab;;
ANY_KERNEL) anykernel;;
PACMAN) update;;
YAOURT) allupdate;;
LOG_PACMAN) /var/log/pacman;;
LOG_XORG) /var/log/Xorg;;
LOG) /var/log;;
CFDISK) cfdisk;;
VERSION) Versionshinweise;;
CPUINFO) CPUINFO;;
MEMORY) MEMORY;;
HDD) HDD;;
TEMP) TEMP;;
QUIT) QUIT;;
esac
}
while true; do
main_menu
done
#endoffile