Skip to content

Commit 6a84248

Browse files
committed
Add simple installer for rpi-clone
1 parent 2fb52fc commit 6a84248

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

install

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# Simple installer for rpi-clone
4+
#
5+
# Downloads and installs rpi-clone and rpi-clone-setup into /usr/local/bin
6+
#
7+
# Command to use to install rpi-clone:
8+
# curl https://github.com/geerlingguy/rpi-clone/blob/master/install | sudo bash
9+
#
10+
# rpi-clone is Copyright (c) 2018-2019 Bill Wilson
11+
#
12+
# Redistribution and use in source and binary forms, with or without
13+
# modification, are permitted under the conditions of the BSD LICENSE file at
14+
# the rpi-clone github source repository:
15+
# https://github.com/billw2/rpi-clone
16+
17+
# This updated code is located in a fork of Bill Willsons git repository
18+
# at https://github.com/geerlingguy/rpi-clone
19+
20+
set -uo pipefail
21+
22+
readonly PACKAGE="rpi-clone"
23+
readonly DOWNLOAD_REPOSITORY="https://github.com/framps/rpi-clone/blob/master"
24+
readonly DOWNLOAD_REPOSITORY_4_MESSAGE="$(sed 's@/blob/master@@' <<< "$DOWNLOAD_REPOSITORY")"
25+
readonly FILES_2_DOWNLOAD"=rpi-clone rpi-clone-setup"
26+
readonly TMP_DIR=$(mktemp -d)
27+
readonly INSTALLATION_DIR="/usr/local/sbin"
28+
29+
trap "{ rmdir $TMP_DIR &>/dev/null; }" SIGINT SIGTERM EXIT
30+
31+
pwd=$PWD
32+
cd $TMP_DIR
33+
34+
echo "Installing $PACKAGE ..."
35+
36+
for file in $FILES_2_DOWNLOAD; do
37+
38+
echo -n "Downloading $file from $DOWNLOAD_REPOSITORY_4_MESSAGE ... "
39+
http_code=$(curl -w "%{http_code}" -L -s $DOWNLOAD_REPOSITORY/$file -o $file)
40+
(( $? )) && { echo "Curl failed"; exit 1; }
41+
[[ $http_code != 200 ]] && { echo "http request failed with $http_code"; exit 1; }
42+
echo "done"
43+
echo -n "Installing $file into $INSTALLATION_DIR ... "
44+
sudo chmod +x $file
45+
(( $? )) && { echo "chmod failed"; exit 1; }
46+
sudo mv $file $INSTALLATION_DIR
47+
(( $? )) && { echo "mv failed"; exit 1; }
48+
echo "done"
49+
50+
done
51+
52+
echo "$PACKAGE installed"
53+
cd $pwd

0 commit comments

Comments
 (0)