-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathRasQ-init.sh
79 lines (67 loc) · 3.64 KB
/
RasQ-init.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
#!/bin/bash
#
# export project / repo name
export REPO=RasQberry-Two # Attention: variable is defined in multiple files
export RQB2_CONFDIR=.local/config # Attention: variable is defined in multiple files
# usage (in RPi terminal):
# wget https://github.com/JanLahmann/RasQberry-Two/raw/main/RasQ-init.sh -O RasQ-init.sh
# . ./RasQ-init.sh
# also use the previous command to update the RasQberry tooling
#
echo; echo;
echo "This script (RasQ-init.sh) downloads a modified raspi-config tool,"
echo "which can be used to install and configure Qiskit and"
echo "several Quantum Computing Demos on the Raspberry Pi"
echo "This script is available at https://github.com/JanLahmann/RasQberry-Two/"
echo;
echo "Before running this script, pls setup the SD card using the"
echo "Raspberry Pi Imager (with 'Raspberry Pi OS 64-bit with Desktop'),"
echo "then login to the RPi via ssh and run the following commands:"
echo;
echo "wget https://github.com/JanLahmann/RasQberry-Two/raw/main/RasQ-init.sh -O RasQ-init.sh"
echo ". ./RasQ-init.sh"
echo "Also use the previous command to update the RasQberry tooling."
echo;
echo "The script be run with parameters . ./RasQ-init.sh branch gituser devoption"
echo "The -branch parameter is used to specify the branch you want to use"
echo "The -gituser parameter is used to specify the github user to use for the rasqberry repository"
echo "The -devoption parameter is used to install the development version of the rasqberry repository (production=0, dev=1)"
echo "default values are: branch=main gituser=JanLahmann devoption=0"
echo "example: . ./RasQ-init.sh main JanLahmann 1"
echo;
echo "See https://rasqberry.org for an in-depth description"
echo "of RasQberry, which combines Raspberry Pi and Qiskit,"
echo "IBM's open source Quantum Computing software framework."
echo;
# to use a differnt branch run e.g. . ./RasQ-init.sh JRL-dev5
BRANCH=${1:-main}
GITUSER=${2:-JanLahmann}
DEVOPTION=${3:-0}
echo "using Branch " $BRANCH "and from github-user " $GITUSER "with DevOption " $DEVOPTION
# to reset local changes run: cd ~/RasQberry-Two; git reset --hard HEAD; cd
cd ~/
# cloning the RasQberry-Two github repo
echo; echo "cloning " $REPO
if [ $DEVOPTION -eq 1 ]; then
echo "using development mode"
[ -d $REPO ] && (cd $REPO; git config pull.rebase false; git fetch --unshallow; git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"; git fetch origin; git pull origin $BRANCH)|| git clone --branch $BRANCH https://github.com/$GITUSER/$REPO
else
echo "using production mode"
[ -d $REPO ] && (cd $REPO; git config pull.rebase false; git pull origin $BRANCH) || git clone --depth 1 --branch $BRANCH https://github.com/$GITUSER/$REPO
fi
# replacing raspi-config with the modified version
echo; echo "replacing raspi-config with the modified version"
wget https://raw.githubusercontent.com/JanLahmann/RasQberry-raspi-config/bookworm/raspi-config -O raspi-config
sudo cp /usr/bin/raspi-config /usr/bin/raspi-config.orig
sudo cp raspi-config /usr/bin
# copy all binaries from the GH repo to ~/.local/bin
echo; echo "copy all binaries from the GH repo to ~/.local/bin"
[ ! -d ~/.local/bin ] && mkdir -p ~/.local/bin
[ -d $REPO/bin ] && cp -r $REPO/bin/* ~/.local/bin
# move all config files from the GH repo to ~/$RQB2_CONFDIR
echo; echo "move all config files from the GH repo to ~/$RQB2_CONFDIR"
[ ! -d ~/$RQB2_CONFDIR ] && mkdir -p ~/$RQB2_CONFDIR
[ -d $REPO/config ] && mv --update $REPO/config/* ~/$RQB2_CONFDIR # be careful: can overwrite modified config file
ln -sf ~/$RQB2_CONFDIR/env-config.sh ~/.local/bin # make env-config.sh avaialable at a default location
echo; echo "RasQ-init.sh finished"
echo "You may now run sudo raspi-config"