a873b26882d7f405ed44b6bad44c39eb532a3edd
3 ##########################################################
5 ##########################################################
7 # Here you can set the default installation directory
9 DEFAULT_TARGET
="/usr/share/gitweb"
14 ##########################################################
16 ##########################################################
18 # (no need to modify, unless you want to)
25 if [[ $
(check_for_symlinks
) == $TRUE && $
(check_for_backups
) == $TRUE ]]
28 log
"[ERROR] - Symlinks and backups found in target, nothing to do."
29 log
"[ERROR] - (Is the theme already installed?)"
34 if [[ $INTERACTIVE == $TRUE ]]
37 if [[ $
(confirm
"Backing up original files, continue?") == $FALSE ]]
46 if [[ $
(check_for_backups
) == $TRUE ]]
48 log
"[NOTICE] - Backups present, skipping..."
53 for FILE
in "${THEME_FILES[@]}"
55 if [[ -e "$TARGET/$FILE.bak" ]]
57 log
"Skipping $FILE.bak, file exists..."
59 mv $MV_ARGS "$TARGET/$FILE" "$TARGET/$FILE.bak"
67 if [[ $INTERACTIVE == $TRUE ]]
70 if [[ $
(confirm
"Linking theme files, continue?") == $FALSE ]]
79 if [[ $
(check_for_symlinks
) == $TRUE ]]
81 log
"[NOTICE] - Symlinks present, skipping..."
86 for FILE
in "${THEME_FILES[@]}"
88 if [[ -h "$TARGET/$FILE" ]]
90 log
"Skipping $FILE, symlink exists..."
92 ln $LN_ARGS "$THEME/$FILE" "$TARGET/$FILE"
101 log
"[NOTICE] - Installation complete!"
109 if [[ $
(check_for_symlinks
"missing") == $TRUE && $
(check_for_backups
"missing") == $TRUE ]]
112 log
"[ERROR] - No symlinks or backups found in target, Nothing to do."
113 log
"[ERROR] - (Is the theme already removed?)"
118 if [[ $INTERACTIVE == $TRUE ]]
121 if [[ $
(confirm
"Deleting symlinks, continue?") == $FALSE ]]
130 if [[ $
(check_for_symlinks
) == $TRUE ]]
133 log
"Deleting symlinks..."
135 for FILE
in "${THEME_FILES[@]}"
137 if [[ -h "$TARGET/$FILE" ]]
139 rm $RM_ARGS "$TARGET/$FILE"
141 log
"Skipping $FILE, not found..."
147 log
"[NOTICE] - Symlinks not found, skipping..."
151 if [[ $INTERACTIVE == $TRUE ]]
154 if [[ $
(confirm
"Restoring original files, continue?") == $FALSE ]]
163 if [[ $
(check_for_backups
) == $TRUE ]]
168 for FILE
in "${THEME_FILES[@]}"
170 if [[ -e "$TARGET/$FILE.bak" ]]
172 mv $MV_ARGS "$TARGET/$FILE.bak" "$TARGET/$FILE"
174 log
"Skipping $FILE.bak, not found..."
180 log
"[NOTICE] - Backups not found, skipping..."
185 log
"[NOTICE] - Removal complete!"
190 if [[ $TARGET && $
(check_for_static
$TARGET) == $TRUE ]]
192 log
"[NOTICE] - Using specified target path: '$TARGET'"
194 if [[ $INTERACTIVE == $TRUE ]]; then
195 if [[ $
(confirm
"Is this correct?") == $FALSE ]]; then
203 TARGET
="$TARGET/static"
205 if [[ $
(check_for_static
$DEFAULT_TARGET) == $TRUE ]]
207 log
"[NOTICE] - Target not set, using default path: '$DEFAULT_TARGET'"
209 if [[ $INTERACTIVE == $TRUE ]]
212 if [[ $
(confirm
"Is this ok?") == $FALSE ]]
221 TARGET
="$DEFAULT_TARGET/static"
224 log
"[ERROR] - Couldn't find folder 'static/' in the target path: '$TARGET'"
225 log
"[ERROR] - (Are you sure this folder contains gitweb?)"
237 if [[ $VERBOSE == $TRUE ]];
244 if [[ $INTERACTIVE == $TRUE ]];
251 if [[ $INTERACTIVE == $TRUE && $VERBOSE == $TRUE ]];
263 if [[ -d "$1/static" ]]
271 #If all present, true
272 #If passed "missing", and all missing, true
277 if [[ $1 == "missing" ]]
281 for FILE
in "${THEME_FILES[@]}"
283 if [[ ! -h "$TARGET/$FILE" ]]
285 COUNT
=$
(expr $COUNT + 1)
289 if [[ $COUNT == "${THEME_FILES[@]}" ]]
296 for FILE
in "${THEME_FILES[@]}"
298 if [[ ! -h "$TARGET/$FILE" ]]
308 #If all present, true
309 #If passed "missing", and all missing, true
314 if [[ $1 == "missing" ]]
318 for FILE
in "${THEME_FILES[@]}"
320 if [[ ! -e "$TARGET/$FILE.bak" ]]
322 COUNT
=$
(expr $COUNT + 1)
326 if [[ $COUNT == "${THEME_FILES[@]}" ]]
333 for FILE
in "${THEME_FILES[@]}"
335 if [[ ! -e "$TARGET/$FILE.bak" ]]
347 read -n 1 -p "$0: $1 [y] | [n] : " REPLY
357 echo "$0: [ERROR] - You must answer [y] | [n]"
365 if [[ $VERBOSE == $TRUE ]]
374 Usage: $0 [-v|-i] [-t <TARGET>|--target <TARGET>] [--install|--remove|--repair]
375 Or: $0 [-V|-h|--version|--help]
377 This script will create symlinks to your gitweb install for themeing.
378 The default location is '/usr/share/gitweb' unless set via -t or --target.
381 -v, --verbose Verbose output
382 -i, --interactive Pauses for confirmation at each step
383 -t, --target Where to create the symlinks, gitweb installation path
384 -h, --help Shows this usage message
385 -V, --version Displays version information
386 --install Adds '.bak' to original files and creates symlinks to theme files
387 --remove Deletes themed symlinks and restores the original files.
388 --repair Removes all theme files, then reinstalls
394 ##########################################################
396 ##########################################################
400 AUTHOR
="Kevin Hill <http://github.com/kevinkhill>"
410 THEME_FILES
=( "gitweb.css" "git-favicon.png" "git-logo.png" )
413 LONG_OPTS
="version,help,verbose,interactive,target:,install,remove,repair"
414 OPTS
=$
(getopt
-o "$SHORT_OPTS" -l "$LONG_OPTS" --name "$0" -- "$@")
423 if [ $# -eq 0 ]; then
424 echo "$0: [ERROR] - no options specified" >&2
428 while [ $# -gt 0 ]; do
445 echo "Gitweb Theme Installer Script - v$PROG_VERSION"
446 echo " Author: $AUTHOR"
463 echo "$0: [ERROR] - unrecognized option $1" >&2