forked from si9ma/Archlinux-Installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.sh
executable file
·87 lines (72 loc) · 1.7 KB
/
app.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
#!/bin/env bash
## author: si9ma
## my blog: si9ma.com
##
## use this cript to install or configure application
##
# don't run this script as root
. log.sh
. no_root.sh
# source restore_script.sh
. restore_script.sh
EXIT_MSG="You have left from Archlinux Installer!"
Config_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
## window
title="Install OR Configure Application"
msg="Please select the Application you want to install or configure. [ESC] to exit the installer"
# get all config from backup.conf
config_list=$(grep -P "^\s*[a-zA-Z0-9-]+\s*[a-zA-Z0-9-]*" backup.conf | xargs)
count=0
for item in $config_list
do
count=$[ $count + 1 ]
judge=$[ $count % 2 ]
if [ "$judge" = "0" ]
then
temp="$temp $item ON"
else
temp="$temp $item"
fi
done
config_list=$temp
### Application Name and description
dialog --no-cancel --ok-label "Go" --ascii-lines --title "$title" --backtitle "$HEADER" --checklist "$msg" 18 75 18 $config_list 2>tempfile
retval=$?
choice=$(cat tempfile)
echo
# ESC to exit
case $retval in
255) # ESC,exit
echo
echo $EXIT_MSG
exit 255
;;
esac
### execute the configuration
for app in $choice
do
restore_$app
if [ "$?" = "0" ]
then
echo "Restore $app successfully!"
else
echo "No restore script for $app!"
fi
done
## complete installation
title="Complete Installation"
msg="Hey! You have completed installation. More details about Archlinux, please see Official wiki."
dialog --no-cancel --ascii-lines --title "$title" --backtitle "$HEADER" --msgbox "$msg" 10 60
retval=$?
choice=$(cat tempfile)
echo
# ESC to exit
case $retval in
255) # ESC,exit
echo
echo $EXIT_MSG
exit 255
;;
esac
# reboot
reboot