Skip to content

Commit d728b51

Browse files
committed
Adjustments for directory marker builds; deployment example fixes to use tini entrypoint correctly
1 parent 3bf4c3a commit d728b51

File tree

8 files changed

+187
-12
lines changed

8 files changed

+187
-12
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
_output/
2-
.vscode
2+
.vscode
3+
rclone-build/

Dockerfile.dm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM golang:alpine AS builder
33
RUN apk update && apk add --no-cache git make bash
44
WORKDIR $GOPATH/src/csi-rclone-nodeplugin
55
COPY . .
6-
RUN make plugin
6+
RUN make plugin-dm
77

88
####
99
FROM alpine:3.16
@@ -13,9 +13,9 @@ RUN apk add --no-cache ca-certificates bash fuse curl unzip tini
1313

1414
# Use pre-compiled version (with cirectory marker patch)
1515
# https://github.com/rclone/rclone/pull/5323
16-
COPY bin/rclone /usr/bin/rclone
17-
RUN chmod 755 /usr/bin/rclone \
18-
&& chown root:root /usr/bin/rclone
16+
COPY ./install-dm.sh /tmp
17+
COPY ./rclone-build /tmp/rclone-build
18+
RUN /tmp/install-dm.sh
1919

2020
COPY --from=builder /go/src/csi-rclone-nodeplugin/_output/csi-rclone-plugin-dm /bin/csi-rclone-plugin
2121

cmd/csi-rclone-plugin/Dockerfile.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ RUN apk add --no-cache ca-certificates bash fuse curl unzip tini
55

66
# Use pre-compiled version (with cirectory marker patch)
77
# https://github.com/rclone/rclone/pull/5323
8-
COPY bin/rclone /usr/bin/rclone
9-
RUN chmod 755 /usr/bin/rclone \
10-
&& chown root:root /usr/bin/rclone
8+
COPY ./install-dm.sh /tmp
9+
COPY ./rclone-build /tmp/rclone-build
10+
RUN /tmp/install-dm.sh
1111

1212
COPY ./_output/csi-rclone-plugin-dm /bin/csi-rclone-plugin
1313

deploy/kubernetes/1.13/csi-controller-rclone.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ spec:
4444
- name: socket-dir
4545
mountPath: /csi
4646
- name: rclone
47-
image: wunderio/csi-rclone:v1.2.8
47+
image: wunderio/csi-rclone:v1.3.0
4848
args :
49+
- "/bin/csi-rclone-plugin"
4950
- "--nodeid=$(NODE_ID)"
5051
- "--endpoint=$(CSI_ENDPOINT)"
5152
env:

deploy/kubernetes/1.13/csi-nodeplugin-rclone.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ spec:
4444
capabilities:
4545
add: ["SYS_ADMIN"]
4646
allowPrivilegeEscalation: true
47-
image: wunderio/csi-rclone:v1.2.8
47+
image: wunderio/csi-rclone:v1.3.0
4848
args:
49+
- "/bin/csi-rclone-plugin"
4950
- "--nodeid=$(NODE_ID)"
5051
- "--endpoint=$(CSI_ENDPOINT)"
5152
env:

deploy/kubernetes/1.19/csi-controller-rclone.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ spec:
3333
- name: socket-dir
3434
mountPath: /csi
3535
- name: rclone
36-
image: wunderio/csi-rclone:v1.2.8
36+
image: wunderio/csi-rclone:v1.3.0
3737
args :
38+
- "/bin/csi-rclone-plugin"
3839
- "--nodeid=$(NODE_ID)"
3940
- "--endpoint=$(CSI_ENDPOINT)"
4041
env:

deploy/kubernetes/1.19/csi-nodeplugin-rclone.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ spec:
4444
capabilities:
4545
add: ["SYS_ADMIN"]
4646
allowPrivilegeEscalation: true
47-
image: wunderio/csi-rclone:v1.2.8
47+
image: wunderio/csi-rclone:v1.3.0
4848
args:
49+
- "/bin/csi-rclone-plugin"
4950
- "--nodeid=$(NODE_ID)"
5051
- "--endpoint=$(CSI_ENDPOINT)"
5152
env:

install-dm.sh

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#!/usr/bin/env bash
2+
3+
# error codes
4+
# 0 - exited without problems
5+
# 1 - parameters not supported were used or some unexpected error occurred
6+
# 2 - OS not supported by this script
7+
# 3 - installed version of rclone is up to date
8+
# 4 - supported unzip tools are not available
9+
10+
set -e
11+
12+
#when adding a tool to the list make sure to also add its corresponding command further in the script
13+
unzip_tools_list=('unzip' '7z' 'busybox')
14+
15+
usage() { echo "Usage: sudo -v ; sudo bash install-dm.sh" 1>&2; exit 1; }
16+
17+
#check for beta flag
18+
if [ -n "$1" ] && [ "$1" != "beta" ]; then
19+
usage
20+
fi
21+
22+
#create tmp directory and move to it with macOS compatibility fallback
23+
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'rclone-install.XXXXXXXXXX')
24+
cd "$tmp_dir"
25+
26+
#make sure unzip tool is available and choose one to work with
27+
set +e
28+
for tool in ${unzip_tools_list[*]}; do
29+
trash=$(hash "$tool" 2>>errors)
30+
if [ "$?" -eq 0 ]; then
31+
unzip_tool="$tool"
32+
break
33+
fi
34+
done
35+
set -e
36+
37+
# exit if no unzip tools available
38+
if [ -z "$unzip_tool" ]; then
39+
printf "\nNone of the supported tools for extracting zip archives (${unzip_tools_list[*]}) were found. "
40+
printf "Please install one of them and try again.\n\n"
41+
exit 4
42+
fi
43+
44+
# Make sure we don't create a root owned .config/rclone directory #2127
45+
export XDG_CONFIG_HOME=config
46+
47+
#detect the platform
48+
OS="$(uname)"
49+
case $OS in
50+
Linux)
51+
OS='linux'
52+
;;
53+
FreeBSD)
54+
OS='freebsd'
55+
;;
56+
NetBSD)
57+
OS='netbsd'
58+
;;
59+
OpenBSD)
60+
OS='openbsd'
61+
;;
62+
Darwin)
63+
OS='osx'
64+
binTgtDir=/usr/local/bin
65+
man1TgtDir=/usr/local/share/man/man1
66+
;;
67+
SunOS)
68+
OS='solaris'
69+
echo 'OS not supported'
70+
exit 2
71+
;;
72+
*)
73+
echo 'OS not supported'
74+
exit 2
75+
;;
76+
esac
77+
78+
OS_type="$(uname -m)"
79+
case "$OS_type" in
80+
x86_64|amd64)
81+
OS_type='amd64'
82+
;;
83+
i?86|x86)
84+
OS_type='386'
85+
;;
86+
aarch64|arm64)
87+
OS_type='arm64'
88+
;;
89+
arm*)
90+
OS_type='arm'
91+
;;
92+
*)
93+
echo 'OS type not supported'
94+
exit 2
95+
;;
96+
esac
97+
98+
99+
#download and unzip
100+
rclone_zip="/tmp/rclone-build/rclone-current-${OS}-${OS_type}.zip"
101+
102+
unzip_dir="tmp_unzip_dir_for_rclone"
103+
# there should be an entry in this switch for each element of unzip_tools_list
104+
case "$unzip_tool" in
105+
'unzip')
106+
unzip -a "$rclone_zip" -d "$unzip_dir"
107+
;;
108+
'7z')
109+
7z x "$rclone_zip" "-o$unzip_dir"
110+
;;
111+
'busybox')
112+
mkdir -p "$unzip_dir"
113+
busybox unzip "$rclone_zip" -d "$unzip_dir"
114+
;;
115+
esac
116+
117+
cd $unzip_dir/*
118+
119+
#mounting rclone to environment
120+
121+
case "$OS" in
122+
'linux')
123+
#binary
124+
cp rclone /usr/bin/rclone.new
125+
chmod 755 /usr/bin/rclone.new
126+
chown root:root /usr/bin/rclone.new
127+
mv /usr/bin/rclone.new /usr/bin/rclone
128+
#manual
129+
if ! [ -x "$(command -v mandb)" ]; then
130+
echo 'mandb not found. The rclone man docs will not be installed.'
131+
else
132+
mkdir -p /usr/local/share/man/man1
133+
cp rclone.1 /usr/local/share/man/man1/
134+
mandb
135+
fi
136+
;;
137+
'freebsd'|'openbsd'|'netbsd')
138+
#binary
139+
cp rclone /usr/bin/rclone.new
140+
chown root:wheel /usr/bin/rclone.new
141+
mv /usr/bin/rclone.new /usr/bin/rclone
142+
#manual
143+
mkdir -p /usr/local/man/man1
144+
cp rclone.1 /usr/local/man/man1/
145+
makewhatis
146+
;;
147+
'osx')
148+
#binary
149+
mkdir -m 0555 -p ${binTgtDir}
150+
cp rclone ${binTgtDir}/rclone.new
151+
mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone
152+
chmod a=x ${binTgtDir}/rclone
153+
#manual
154+
mkdir -m 0555 -p ${man1TgtDir}
155+
cp rclone.1 ${man1TgtDir}
156+
chmod a=r ${man1TgtDir}/rclone.1
157+
;;
158+
*)
159+
echo 'OS not supported'
160+
exit 2
161+
esac
162+
163+
164+
#update version variable post install
165+
version=$(rclone --version 2>>errors | head -n 1)
166+
167+
printf "\n${version} has successfully installed."
168+
printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'
169+
exit 0
170+

0 commit comments

Comments
 (0)