-
Notifications
You must be signed in to change notification settings - Fork 0
/
podman.sh
executable file
·117 lines (74 loc) · 2.15 KB
/
podman.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Author Sabuhi Shukurov
VERSION="0.3"
ISSUE_URL="https://github.com/sabuhish/easy-podman-cli/issues"
README_URL="https://github.com/sabuhish/easy-podman-cli/blob/master/README.md"
SCRIPT_URL="https://raw.githubusercontent.com/sabuhish/easy-podman-cli/master/commands"
CURRENT_DIRECTORY=$(pwd)
COMMANDS_DIRECTORY=/usr/local/bin/
# The set -e option instructs bash to immediately exit if any command [1] has a non-zero exit status
set -e
function proceed_before_apply(){
if [ -e $CURRENT_DIRECTORY/commands/$1 ]; then
cd $CURRENT_DIRECTORY/commands
cp $1 $COMMANDS_DIRECTORY
else
curl "$SCRIPT_URL/commands/$1" -o $1
mv $1 $COMMANDS_DIRECTORY
fi
}
function build_podman(){
proceed_before_apply build-podman
}
function connect_container(){
proceed_before_apply connect-podman
}
function podman_restart(){
proceed_before_apply restart-podman
}
function podman_restart_compose(){
proceed_before_apply restart-podman-compose
}
function dangling_remove_podman(){
proceed_before_apply dangling-podman
}
function podman_compose_logs(){
proceed_before_apply podman-compose-logs
}
function down_podman_containers(){
proceed_before_apply down-podman
}
function usage(){
proceed_before_apply easy-podman
}
function apply_comands(){
#checking if user is root 0 => root !0 is non-root user
if [[ $EUID -eq 0 ]]; then
dangling_remove_podman
connect_container
build_podman
down_podman_containers
podman_compose_logs
podman_restart
podman_restart_compose
usage
cd $COMMANDS_DIRECTORY
chmod +x dangling-podman
chmod +x connect-podman
chmod +x build-podman
chmod +x down-podman
chmod +x podman-compose-logs
chmod +x restart-podman
chmod +x restart-podman-compose
chmod +x easy-podman
cd $CURRENT_DIRECTORY
else
# dangling_remove_podman
# cd $COMMANDS_DIRECTORY
# chmod +x dangling-podman
# cd $CURRENT_DIRECTORY
echo "Not root user"
fi
}
apply_comands
# rm -rf podman.sh