Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
34109863
Commit
34109863
authored
Mar 06, 2020
by
Erik Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update install script for rpm install
parent
2071247a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
install.sh
install.sh
+25
-20
No files found.
install.sh
View file @
34109863
...
@@ -26,6 +26,9 @@ set -e
...
@@ -26,6 +26,9 @@ set -e
# If set to 'skip' will not create symlinks, 'force' will overwrite,
# If set to 'skip' will not create symlinks, 'force' will overwrite,
# default will symlink if command does not exist in path.
# default will symlink if command does not exist in path.
#
#
# - INSTALL_K3S_SKIP_ENABLE
# If set to true will not enable or start k3s service.
#
# - INSTALL_K3S_SKIP_START
# - INSTALL_K3S_SKIP_START
# If set to true will not start k3s service.
# If set to true will not start k3s service.
#
#
...
@@ -166,11 +169,6 @@ setup_env() {
...
@@ -166,11 +169,6 @@ setup_env() {
${
invalid_chars
}
"
${
invalid_chars
}
"
fi
fi
# --- set related files from system name ---
SERVICE_K3S
=
${
SYSTEM_NAME
}
.service
UNINSTALL_K3S_SH
=
${
SYSTEM_NAME
}
-uninstall
.sh
KILLALL_K3S_SH
=
k3s-killall.sh
# --- use sudo if we are not already root ---
# --- use sudo if we are not already root ---
SUDO
=
sudo
SUDO
=
sudo
if
[
$(
id
-u
)
-eq
0
]
;
then
if
[
$(
id
-u
)
-eq
0
]
;
then
...
@@ -202,6 +200,11 @@ setup_env() {
...
@@ -202,6 +200,11 @@ setup_env() {
SYSTEMD_DIR
=
/etc/systemd/system
SYSTEMD_DIR
=
/etc/systemd/system
fi
fi
# --- set related files from system name ---
SERVICE_K3S
=
${
SYSTEM_NAME
}
.service
UNINSTALL_K3S_SH
=
${
UNINSTALL_K3S_SH
:-${
BIN_DIR
}
/
${
SYSTEM_NAME
}
-uninstall.sh
}
KILLALL_K3S_SH
=
${
KILLALL_K3S_SH
:-${
BIN_DIR
}
/k3s-killall.sh
}
# --- use service or environment location depending on systemd/openrc ---
# --- use service or environment location depending on systemd/openrc ---
if
[
"
${
HAS_SYSTEMD
}
"
=
true
]
;
then
if
[
"
${
HAS_SYSTEMD
}
"
=
true
]
;
then
FILE_K3S_SERVICE
=
${
SYSTEMD_DIR
}
/
${
SERVICE_K3S
}
FILE_K3S_SERVICE
=
${
SYSTEMD_DIR
}
/
${
SERVICE_K3S
}
...
@@ -396,7 +399,7 @@ setup_binary() {
...
@@ -396,7 +399,7 @@ setup_binary() {
$SUDO
chown
root:root
${
TMP_BIN
}
$SUDO
chown
root:root
${
TMP_BIN
}
$SUDO
mv
-f
${
TMP_BIN
}
${
BIN_DIR
}
/k3s
$SUDO
mv
-f
${
TMP_BIN
}
${
BIN_DIR
}
/k3s
if
command
-v
getenforce
>
/dev/null 2>&1
;
then
if
command
-v
getenforce
>
/dev/null 2>&1
;
then
if
[
"Disabled"
!=
$(
getenforce
)
]
;
then
if
[
"Disabled"
!=
$(
getenforce
)
]
;
then
info
'SELinux is enabled, setting permissions'
info
'SELinux is enabled, setting permissions'
if
!
$SUDO
semanage fcontext
-l
|
grep
"
${
BIN_DIR
}
/k3s"
>
/dev/null 2>&1
;
then
if
!
$SUDO
semanage fcontext
-l
|
grep
"
${
BIN_DIR
}
/k3s"
>
/dev/null 2>&1
;
then
...
@@ -439,7 +442,7 @@ create_symlinks() {
...
@@ -439,7 +442,7 @@ create_symlinks() {
for
cmd
in
kubectl crictl ctr
;
do
for
cmd
in
kubectl crictl ctr
;
do
if
[
!
-e
${
BIN_DIR
}
/
${
cmd
}
]
||
[
"
${
INSTALL_K3S_SYMLINK
}
"
=
force
]
;
then
if
[
!
-e
${
BIN_DIR
}
/
${
cmd
}
]
||
[
"
${
INSTALL_K3S_SYMLINK
}
"
=
force
]
;
then
which_cmd
=
$(
which
${
cmd
}
||
true
)
which_cmd
=
$(
which
${
cmd
}
2>/dev/null
||
true
)
if
[
-z
"
${
which_cmd
}
"
]
||
[
"
${
INSTALL_K3S_SYMLINK
}
"
=
force
]
;
then
if
[
-z
"
${
which_cmd
}
"
]
||
[
"
${
INSTALL_K3S_SYMLINK
}
"
=
force
]
;
then
info
"Creating
${
BIN_DIR
}
/
${
cmd
}
symlink to k3s"
info
"Creating
${
BIN_DIR
}
/
${
cmd
}
symlink to k3s"
$SUDO
ln
-sf
k3s
${
BIN_DIR
}
/
${
cmd
}
$SUDO
ln
-sf
k3s
${
BIN_DIR
}
/
${
cmd
}
...
@@ -455,13 +458,13 @@ create_symlinks() {
...
@@ -455,13 +458,13 @@ create_symlinks() {
# --- create killall script ---
# --- create killall script ---
create_killall
()
{
create_killall
()
{
[
"
${
INSTALL_K3S_BIN_DIR_READ_ONLY
}
"
=
true
]
&&
return
[
"
${
INSTALL_K3S_BIN_DIR_READ_ONLY
}
"
=
true
]
&&
return
info
"Creating killall script
${
BIN_DIR
}
/
${
KILLALL_K3S_SH
}
"
info
"Creating killall script
${
KILLALL_K3S_SH
}
"
$SUDO
tee
${
BIN_DIR
}
/
${
KILLALL_K3S_SH
}
>
/dev/null
<<
\
EOF
$SUDO
tee
${
KILLALL_K3S_SH
}
>
/dev/null
<<
\
EOF
#!/bin/sh
#!/bin/sh
[
$(
id
-u
)
-eq 0 ] || exec sudo
$0
$@
[
$(
id
-u
)
-eq 0 ] || exec sudo
$0
$@
for bin in /var/lib/rancher/k3s/data/**/bin/; do
for bin in /var/lib/rancher/k3s/data/**/bin/; do
[ -d
$bin
] && export PATH=
$
bin
:
$PATH
[ -d
$bin
] && export PATH=
$
PATH
:
$bin
:
$bin
/aux
done
done
set -x
set -x
...
@@ -499,7 +502,7 @@ killtree() {
...
@@ -499,7 +502,7 @@ killtree() {
}
}
getshims() {
getshims() {
lsof | sed -e 's/^[^0-9]*//g; s/ */\t/g' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 | sort -n -u
ps -e -o pid= -o args= | sed -e 's/^ *//; s/\s\s*/\t/;' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1
}
}
killtree
$(
{
set
+x
;
}
2>/dev/null
;
getshims
;
set
-x
)
killtree
$(
{
set
+x
;
}
2>/dev/null
;
getshims
;
set
-x
)
...
@@ -534,20 +537,20 @@ ip link delete flannel.1
...
@@ -534,20 +537,20 @@ ip link delete flannel.1
rm -rf /var/lib/cni/
rm -rf /var/lib/cni/
iptables-save | grep -v KUBE- | grep -v CNI- | iptables-restore
iptables-save | grep -v KUBE- | grep -v CNI- | iptables-restore
EOF
EOF
$SUDO
chmod
755
${
BIN_DIR
}
/
${
KILLALL_K3S_SH
}
$SUDO
chmod
755
${
KILLALL_K3S_SH
}
$SUDO
chown
root:root
${
BIN_DIR
}
/
${
KILLALL_K3S_SH
}
$SUDO
chown
root:root
${
KILLALL_K3S_SH
}
}
}
# --- create uninstall script ---
# --- create uninstall script ---
create_uninstall
()
{
create_uninstall
()
{
[
"
${
INSTALL_K3S_BIN_DIR_READ_ONLY
}
"
=
true
]
&&
return
[
"
${
INSTALL_K3S_BIN_DIR_READ_ONLY
}
"
=
true
]
&&
return
info
"Creating uninstall script
${
BIN_DIR
}
/
${
UNINSTALL_K3S_SH
}
"
info
"Creating uninstall script
${
UNINSTALL_K3S_SH
}
"
$SUDO
tee
${
BIN_DIR
}
/
${
UNINSTALL_K3S_SH
}
>
/dev/null
<<
EOF
$SUDO
tee
${
UNINSTALL_K3S_SH
}
>
/dev/null
<<
EOF
#!/bin/sh
#!/bin/sh
set -x
set -x
[ \
$(
id
-u
)
-eq 0 ] || exec sudo \
$0
\
$@
[ \
$(
id
-u
)
-eq 0 ] || exec sudo \
$0
\
$@
${
BIN_DIR
}
/
${
KILLALL_K3S_SH
}
${
KILLALL_K3S_SH
}
if which systemctl; then
if which systemctl; then
systemctl disable
${
SYSTEM_NAME
}
systemctl disable
${
SYSTEM_NAME
}
...
@@ -562,7 +565,7 @@ rm -f ${FILE_K3S_SERVICE}
...
@@ -562,7 +565,7 @@ rm -f ${FILE_K3S_SERVICE}
rm -f
${
FILE_K3S_ENV
}
rm -f
${
FILE_K3S_ENV
}
remove_uninstall() {
remove_uninstall() {
rm -f
${
BIN_DIR
}
/
${
UNINSTALL_K3S_SH
}
rm -f
${
UNINSTALL_K3S_SH
}
}
}
trap remove_uninstall EXIT
trap remove_uninstall EXIT
...
@@ -581,10 +584,10 @@ rm -rf /etc/rancher/k3s
...
@@ -581,10 +584,10 @@ rm -rf /etc/rancher/k3s
rm -rf /var/lib/rancher/k3s
rm -rf /var/lib/rancher/k3s
rm -rf /var/lib/kubelet
rm -rf /var/lib/kubelet
rm -f
${
BIN_DIR
}
/k3s
rm -f
${
BIN_DIR
}
/k3s
rm -f
${
BIN_DIR
}
/
${
KILLALL_K3S_SH
}
rm -f
${
KILLALL_K3S_SH
}
EOF
EOF
$SUDO
chmod
755
${
BIN_DIR
}
/
${
UNINSTALL_K3S_SH
}
$SUDO
chmod
755
${
UNINSTALL_K3S_SH
}
$SUDO
chown
root:root
${
BIN_DIR
}
/
${
UNINSTALL_K3S_SH
}
$SUDO
chown
root:root
${
UNINSTALL_K3S_SH
}
}
}
# --- disable current service if loaded --
# --- disable current service if loaded --
...
@@ -718,6 +721,8 @@ openrc_start() {
...
@@ -718,6 +721,8 @@ openrc_start() {
# --- startup systemd or openrc service ---
# --- startup systemd or openrc service ---
service_enable_and_start
()
{
service_enable_and_start
()
{
[
"
${
INSTALL_K3S_SKIP_ENABLE
}
"
=
true
]
&&
return
[
"
${
HAS_SYSTEMD
}
"
=
true
]
&&
systemd_enable
[
"
${
HAS_SYSTEMD
}
"
=
true
]
&&
systemd_enable
[
"
${
HAS_OPENRC
}
"
=
true
]
&&
openrc_enable
[
"
${
HAS_OPENRC
}
"
=
true
]
&&
openrc_enable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment