You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
18 years ago
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||
17 years ago
|
#
|
||
16 years ago
|
# Filename: package/.../sysfiles/etc_init.d_functions-ansi.in.txt
|
||
|
# Copyright (C) 2006 - 2009 The OpenSDE Project
|
||
17 years ago
|
#
|
||
18 years ago
|
# More information can be found in the files COPYING and README.
|
||
17 years ago
|
#
|
||
18 years ago
|
# This program is free software; you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
||
|
# GNU General Public License can be found in the file COPYING.
|
||
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
||
|
|
||
|
# http://en.wikipedia.org/wiki/ANSI_escape_code
|
||
|
#
|
||
|
|
||
|
ECHO='echo -e'
|
||
18 years ago
|
ESC='\e' # \e or \033
|
||
|
BELL='\a' # \a or 07
|
||
18 years ago
|
|
||
18 years ago
|
ART_SUCCESS=" OK "
|
||
|
ART_FAILURE=" FAIL"
|
||
18 years ago
|
ART_NEXT=" v "
|
||
|
|
||
17 years ago
|
COLOR_BANNER="$ESC[35;1m" # magenta
|
||
18 years ago
|
COLOR_TITLE="$ESC[36m" # cyan
|
||
|
COLOR_NORMAL="$ESC[0m" # default (no attributes)
|
||
|
COLOR_SUCCESS="$ESC[32m" # green
|
||
|
COLOR_FAILURE="$ESC[31m" # red
|
||
|
|
||
|
MOVE_EOL="$ESC[222G" # 222 columns to the right... kind-of-eol
|
||
|
MOVE_UP="$ESC[1A" # 1 line up (eat last \n)
|
||
|
|
||
18 years ago
|
MOVE_LEFT_STATUS="$ESC[$( expr ${#ART_SUCCESS} - 1 )D" # move left the length of $ART_SUCCESS
|
||
|
MOVE_LEFT_NEXT="$ESC[$( expr ${#ART_NEXT} - 1 )D" # move left the length of $ART_NEXT
|
||
18 years ago
|
|
||
16 years ago
|
banner() {
|
||
17 years ago
|
$ECHO "$COLOR_BANNER$*$COLOR_NORMAL"
|
||
|
}
|
||
|
|
||
16 years ago
|
title() {
|
||
18 years ago
|
local x=1 columns=
|
||
|
columns=$( if ! stty size -F /dev/tty; then
|
||
|
stty size -F /dev/console
|
||
|
fi 2> /dev/null | cut -d' ' -f2 )
|
||
|
[ -n "$columns" ] || columns=80
|
||
|
|
||
|
# fill with dots with an "arrow" pointing down at the end.
|
||
|
for (( x=1; x<columns; x++ )); do
|
||
|
$ECHO -n '.'
|
||
|
done
|
||
|
$ECHO -n "$MOVE_LEFT_NEXT$ART_NEXT\r"
|
||
17 years ago
|
|
||
18 years ago
|
# and the title
|
||
|
$ECHO "$COLOR_TITLE$* $COLOR_NORMAL"
|
||
|
error=0
|
||
|
}
|
||
|
|
||
16 years ago
|
status() {
|
||
18 years ago
|
$ECHO -n "$MOVE_UP$MOVE_EOL$MOVE_LEFT_STATUS"
|
||
16 years ago
|
if [ "${1:-$error}" -eq 0 ]; then
|
||
18 years ago
|
$ECHO "$COLOR_SUCCESS$ART_SUCCESS$COLOR_NORMAL"
|
||
|
else
|
||
|
$ECHO "$BELL$COLOR_FAILURE$ART_FAILURE$COLOR_NORMAL"
|
||
|
fi
|
||
|
}
|