Debian Codegraph @

bin/container-shell

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Copyright (C) 2014-2026 Daniel Baumann <[email protected]>
4 #
5 # SPDX-License-Identifier: GPL-3.0+
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 set -e
21
22 PROJECT="open-infrastructure"
23 SOFTWARE="compute-tools"
24 PROGRAM="container"
25
26 COMMAND="$(basenamescip-shell system . . basename. ${0})"
27
28 LC_ALL="C.UTF-8"
29
30 Usagescip-shell shell shell-project 0.0.0 Usage(). ()
31 {
32 echoscip-shell system . . echo. "Usage: ${PROGRAM}-shell" >&2
33 exit 1
34 }
35
36 Shellscip-shell shell shell-project 0.0.0 Shell(). ()
37 {
38 COMMAND="${1}"
39
40 if [scip-shell system . . `[`. -z "${COMMAND}" ]
41 then
42 return
43 fi
44
45 shift 1
46
47 OPTIONS="${@}"
48
49 case "${COMMAND}" in
50 about)
51 manscip-shell system . . man. ${PROGRAM} || truescip-shell system . . true.
52
53 return
54 ;;
55
56 logout|exit)
57 exit 0
58 ;;
59
60 help)
61 case "${OPTIONS}" in
62 "")
63 echoscip-shell system . . echo.
64 echoscip-shell system . . echo. "The following ${PROGRAM} commands are available:"
65 echoscip-shell system . . echo.
66
67 cd "/usr/libexec/${PROGRAM}"
68 findscip-shell system . . find. . -type f -printf " %f\n" | sortscip-shell system . . sort.
69 cd "${OLDPWD}"
70
71 if [scip-shell system . . `[`. -n "${CONTAINER_COMMANDS_ENABLE}" ]
72 then
73 echoscip-shell system . . echo.
74 echoscip-shell system . . echo. "The following container commands are enabled for the current user:"
75 echoscip-shell system . . echo. " ${CONTAINER_COMMANDS_ENABLE}"
76 fi
77
78 if [scip-shell system . . `[`. -n "${CONTAINER_COMMANDS_DISABLE}" ]
79 then
80 echoscip-shell system . . echo.
81 echoscip-shell system . . echo. "The following container commands are disabled for the current user:"
82 echoscip-shell system . . echo. " ${CONTAINER_COMMANDS_DISABLE}"
83 fi
84
85 echoscip-shell system . . echo.
86 echoscip-shell system . . echo. "Use 'help COMMAND' for more information."
87
88 return
89 ;;
90
91 *)
92 manscip-shell system . . man. ${PROGRAM}-${1} || truescip-shell system . . true.
93
94 return
95 ;;
96 esac
97 ;;
98 esac
99
100 if [scip-shell system . . `[`. ! -e "/usr/libexec/${PROGRAM}/${COMMAND}" ]
101 then
102 echoscip-shell system . . echo. "'${COMMAND}': no such ${PROGRAM} command" >&2
103 return
104 fi
105
106 if [scip-shell system . . `[`. -n "${CONTAINER_COMMANDS_ENABLE}" ]
107 then
108 COMMAND_ALLOWED=""
109
110 for CONTAINER_COMMAND in ${CONTAINER_COMMANDS_ENABLE}
111 do
112 case "${CONTAINER_COMMAND}" in
113 ${COMMAND}|all|about|logout|exit|help)
114 COMMAND_ALLOWED="true"
115 ;;
116 esac
117 done
118
119 case "${COMMAND_ALLOWED}" in
120 true)
121 ;;
122
123 *)
124 echoscip-shell system . . echo. "'${COMMAND}': command not allowed for current user" >&2
125 return
126 ;;
127 esac
128 fi
129
130 if [scip-shell system . . `[`. -n "${CONTAINER_COMMANDS_DISABLE}" ]
131 then
132 COMMAND_DISALLOWED=""
133
134 for CONTAINER_COMMAND in ${CONTAINER_COMMANDS_DISABLE}
135 do
136 case "${CONTAINER_COMMAND}" in
137 ${COMMAND}|all|about|logout|exit|help)
138 COMMAND_DISALLOWED="true"
139 ;;
140 esac
141 done
142
143 case "${COMMAND_DISALLOWED}" in
144 true)
145 echoscip-shell system . . echo. "'${COMMAND}': command not allowed for current user" >&2
146 return
147 ;;
148 esac
149 fi
150
151 echoscip-shell system . . echo.
152 sudoscip-shell system . . sudo. ${PROGRAM} ${COMMAND} ${OPTIONS} || truescip-shell system . . true.
153 }
154
155 trap 'echo' EXIT HUP INT QUIT TERM
156
157 echoscip-shell system . . echo. "${SOFTWARE} $(${PROGRAM} version)"
158 echoscip-shell system . . echo. "Type \"about\" or \"help\" for more information, \"logout\" to exit."
159
160 while truescip-shell system . . true.
161 do
162 echoscip-shell system . . echo.
163 echoscip-shell system . . echo. -n "${PROGRAM}: "
164 read CMDLINE
165
166 Shellscip-shell shell shell-project 0.0.0 Shell(). ${CMDLINE}
167 done