tinycm view tinycm @ rev 79

Small cosmetic vhange to user profile
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 11 00:26:31 2017 +0100 (2017-02-11)
parents 33e6a5c881ec
children f587a0fa5435
line source
1 #!/bin/sh
2 #
3 # TinyCM Command line tool. Dont use libtaz since TinyCM can run on any
4 # Linux/BSD distribution providing a web server with CGI SHell support
5 # such as LightTPD.
6 #
7 # Copyright (C) 2014 SliTaz GNU/Linux - BSD License
8 #
10 list="tinycm.list"
11 path="${2%/}"
12 hgurl="http://hg.slitaz.org/tinycm"
13 dlurl="$hgurl/archive/tip.tar.bz2"
15 #
16 # Functions
17 #
19 boldify() {
20 echo -e "\\033[1m$@\\033[0m"
21 }
23 error() {
24 echo -e "\\033[1;31m$@\\033[0;39m"
25 }
27 usage() {
28 cat << EOT
30 $(boldify "Usage:") $(basename $0) [command] [path|list]
32 $(boldify "Commands:")
33 inst Install TinyCM and set permissions
34 up Update one or a list of TinyCM installations
36 EOT
37 }
39 check_source() {
40 if [ ! -f "Makefile" ] || [ ! -f "index.cgi" ]; then
41 error "No source found" && exit 1
42 fi
43 }
45 check_path() {
46 if [ ! "$path" ]; then
47 error "Missing path argument" && exit 1
48 fi
49 }
51 check_tiny() {
52 if [ ! -f "$path/index.cgi" ] || [ ! -d "$path/lib" ]; then
53 error "Missing TinyCM in: $path"
54 continue
55 fi
56 }
58 #
59 # Commands
60 #
62 case "$1" in
63 inst)
64 check_source
65 check_path
66 echo ""
67 boldify "Installing TinyCM..."
68 echo "Path:"; echo "$path"
69 mkdir -p $path
70 for file in index.cgi style.css images lib plugins
71 do
72 cp -a $file $path
73 done
74 if [ $(id) == 0 ]; then
75 echo root
76 else
77 echo user
78 fi
79 echo "" ;;
80 up)
81 check_source
82 if [ ! "$path" ] && [ ! -f "$list" ]; then
83 error "Missing path argument or paths list: $list"
84 exit 1
85 fi
86 echo ""
87 boldify $(echo "Updating TinyCM installs...")
89 # File liste of args
90 if [ -f "$path" ]; then
91 paths="$(cat ${list})"
92 else
93 paths="$path"
94 fi
96 for path in ${paths}
97 do
98 check_tiny
99 echo "Updating: $path"
100 cp -a index.cgi $path
101 cp -a lib/functions.js $path/lib
102 cp -a lib/jseditor.html $path/lib
103 for plug in $(ls plugins)
104 do
105 if [ -d "$path/plugins/$plug" ]; then
106 echo "* Updating plugin: $plug"
107 cp -a plugins/$plug $path/plugins
108 fi
109 done
110 done && echo "" ;;
111 *)
112 usage ;;
113 esac
115 exit 0