tinycm view tinycm @ rev 86

Update French translation
author Christophe Lincoln <pankso@slitaz.org>
date Sun Feb 12 00:13:50 2017 +0100 (2017-02-12)
parents 4e8dfb19f2a7
children 95673a3de4e4
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-2017 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 echo "* Installing: $file"
73 cp -a $file $path
74 done
75 if [ $(id) == 0 ]; then
76 echo root
77 else
78 echo user
79 fi
80 echo "" ;;
81 up)
82 check_source
83 if [ ! "$path" ] && [ ! -f "$list" ]; then
84 error "Missing path argument or paths list: $list"
85 exit 1
86 fi
87 echo ""
88 boldify $(echo "Updating TinyCM installs...")
90 # File liste of args
91 if [ -f "$path" ]; then
92 paths="$(cat ${list})"
93 else
94 paths="$path"
95 fi
97 for path in ${paths}
98 do
99 check_tiny
100 echo "Updating: $path"
101 cp -a index.cgi $path
102 cp -a lib/functions.js $path/lib
103 cp -a lib/jseditor.html $path/lib
104 for plug in $(ls plugins)
105 do
106 if [ -d "$path/plugins/$plug" ]; then
107 echo "* Updating plugin: $plug"
108 cp -a plugins/$plug $path/plugins
109 fi
110 done
111 done && echo "" ;;
112 *)
113 usage ;;
114 esac
116 exit 0