~thbraeutigam/x10customizer/main

« back to all changes in this revision

Viewing changes to program/bin/120_theme_install.sh

  • Committer: thbraeutigam
  • Date: 2010-11-22 02:40:12 UTC
  • Revision ID: thorben.braeutigam@gmail.com-20101122024012-tq4tznx1rzdrugc5
v0.99.2pre

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#HIDDENSCRIPT
 
3
###
 
4
# x10 2.1 Configurator
 
5
# (c) 2010 ttxdragon
 
6
# Licensed under GPL v2
 
7
##
 
8
 
 
9
###
 
10
# Documentation Portion
 
11
##
 
12
 
 
13
###
 
14
# Menu Entry Name for Selector:
 
15
#& Install Themes
 
16
##
 
17
#*****************************************************************************#
 
18
#* This installs themes packaged in .x10theme format.                        *#
 
19
#* Other formats (fe. chewitts installer, custom install.sh) are NOT usable. *#
 
20
#*****************************************************************************#
 
21
 
 
22
 
 
23
####
 
24
#  Dev Documentation:
 
25
#  $1 -> project root
 
26
##
 
27
 
 
28
if [ -d /cygdrive ]
 
29
then
 
30
    ###
 
31
    # Variables for Windows
 
32
    # Path for windows is set in its bat-file
 
33
    ##
 
34
    adb="adb.exe"
 
35
elif [ "`uname`" = "Linux" ]
 
36
then
 
37
    ###
 
38
    # Variables for Linux
 
39
    # Initialising adb with a request for root permissions
 
40
    # since it otherwise decides to fail with
 
41
    # "not enough permissions to access device"
 
42
    ##
 
43
    adb="adb"
 
44
    PATH=$PATH:"$croot/program/bin/lin/"
 
45
    cd "$croot/program/bin/lin/"
 
46
    chmod +x ./adb
 
47
    echo "Starting Android Debug Bridge. Need Root Permissions. Using Sudo:"
 
48
    sudo ./adb devices
 
49
    cd "$croot"
 
50
else
 
51
    echo "Couldn't find supported OS. Aborting."
 
52
    exit 0
 
53
fi
 
54
if [ ! $(($adb devices | grep -v "devices")) ]
 
55
    then
 
56
    echo "Can't find an attached phone! Please connect your phone and re-start the task."
 
57
    cd "$croot/program"
 
58
    bash ./selector "$1"
 
59
fi
 
60
 
 
61
show_info()
 
62
{
 
63
    ###
 
64
    # echo out the info from config-files
 
65
    ##
 
66
    clear
 
67
    cd "$2/config"
 
68
    strings $4 | grep "^\#\*.*\*#$"
 
69
    echo "Press Enter to return to menu"
 
70
    read input
 
71
    unset $input
 
72
    clear
 
73
    cd "$2/program/bin"
 
74
    bash "$1" "$2" "$3"
 
75
    
 
76
 
 
77
}
 
78
 
 
79
function excfg {
 
80
    ###
 
81
    # Extract Configuration for Usage
 
82
    # $1 -> config file to use
 
83
    ##
 
84
    cp "$croot/config/$1" "$cfgtmp/"
 
85
 
 
86
    cd "$cfgtmp"
 
87
    tar -xf "$1"
 
88
    rm "$1"
 
89
    tar -xzf "config.tgz"
 
90
    rm "config.tgz"
 
91
    if [ -e "customization.tgz" ]
 
92
        then
 
93
        tar -xzf "customization.tgz"
 
94
        rm "customization.tgz"
 
95
    fi
 
96
    cd "$croot"
 
97
}
 
98
 
 
99
###
 
100
# Execution
 
101
##
 
102
 
 
103
###
 
104
# If there's already a config-tmp directory, delete it and put an empty one
 
105
# into its place for population with new cfg files.
 
106
##
 
107
croot=$1
 
108
cfgtmp="$croot/program/tmptheme"
 
109
if [ -d "$cfgtmp" ]
 
110
then
 
111
    cd "$croot/program/"
 
112
    rm -r tmp
 
113
fi
 
114
mkdir -p "$cfgtmp"
 
115
 
 
116
cd "$croot/themes/"
 
117
 
 
118
OLD_IFS=$IFS
 
119
IFS='
 
120
'
 
121
if [ ! `ls -1 *.x10conf | wc -l` = "0" ]
 
122
then
 
123
    for conf in `ls -1 *.x10theme`
 
124
        do
 
125
            ccount=$(($ccount+1))
 
126
            conff[$ccount]=$conf
 
127
    done
 
128
 
 
129
    echo "Found the following configurations: "
 
130
    
 
131
    for i in `seq 1 $ccount`
 
132
        do
 
133
            echo "  $i. `strings ${conff[$i]} | grep "\#N\ " | sed -e "s_\#N\ __g"`"
 
134
    done
 
135
 
 
136
    echo "Use 'ask #' to get help on what each theme is specifically."
 
137
    printf "Please select which one to use (enter 0 for backup): "
 
138
    read choice
 
139
    
 
140
    if [ `echo $choice | grep "ask\ [0-9]"` ]
 
141
        then
 
142
            show_info $0 $1 $2 ${conff[`echo $choice | sed -e "s_ask\ __"`]}
 
143
    elif [ "$choice" = "0" ]
 
144
    then
 
145
        echo "Using Default Configuration as base"
 
146
        cd "$cfgtmp"
 
147
        $adb pull /sdcard/backup/theme/
 
148
    elif [ "$choice" -le "$ccount" ]
 
149
    then
 
150
        echo "Using ${conff[$choice]} as base."
 
151
        excfg "${conff[$choice]}"
 
152
    else
 
153
        clear
 
154
        echo "Can't seem to find the file you chose. Aborting."
 
155
        cd "$croot"
 
156
        bash ./program/selector "$croot"
 
157
    fi
 
158
else
 
159
    echo "No Themes found. Aborting."
 
160
    
 
161
fi
 
162
 
 
163
cd "$croot/program/bin"
 
164
bash "$2" "$croot" "true" 2> "$croot/local-logs/$2.txt"