Skip to content

Commit 35c18a1

Browse files
committed
first steps
1 parent 2f2640f commit 35c18a1

File tree

2 files changed

+78
-25
lines changed

2 files changed

+78
-25
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check the getting-started.sh script
2+
3+
on:
4+
push:
5+
branches:
6+
- rzadp/getting-started
7+
merge_group:
8+
9+
jobs:
10+
check-getting-started:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Install prerequisites
14+
run: |
15+
apt update
16+
apt install -y expect
17+
- name: Check the script
18+
run: |
19+
cat << EOF | expect -f -
20+
spawn bash scripts/getting-started.sh
21+
expect "Detected Ubuntu"
22+
EOF
23+
timeout-miuntes: 3

scripts/getting-started.sh

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
prompt() {
66
while true; do
7-
echo -e "$1 [y/N]"
7+
printf "$1 [y/N]\n"
88
read yn
99
case $yn in
1010
[Yy]* ) return 0;; # Yes, return 0 (true)
@@ -17,7 +17,7 @@ prompt() {
1717

1818
prompt_default_yes() {
1919
while true; do
20-
echo -e "$1 [Y/n]"
20+
printf "$1 [Y/n]\n"
2121
read yn
2222
case $yn in
2323
[Yy]* ) return 0;; # Yes, return 0 (true)
@@ -28,6 +28,17 @@ prompt_default_yes() {
2828
done
2929
}
3030

31+
clone_and_enter_template() {
32+
template="$1" # minimal, solochain, or parachain
33+
if [ -d "${template}-template" ]; then
34+
printf "\n✅︎ ${template}-template directory already exists. -> Entering.\n"
35+
else
36+
printf "\n↓ Let's grab the ${template} template from github.\n"
37+
git clone https://github.com/paritytech/polkadot-sdk-${template}-template.git ${template}-template
38+
fi
39+
cd ${template}-template
40+
}
41+
3142
cat <<EOF
3243
3344
Welcome to the
@@ -39,7 +50,7 @@ cat <<EOF
3950
| \__/ |__/| \_/\_/|_/\_/|_/\__/ |_/ |____/|____/|_|\_\
4051
quickstart!
4152
42-
⚡ We will be setting up an example template and its environment for you to experiment with.
53+
⚡ We will help setting up the environment for you to experiment with.
4354
EOF
4455

4556
# Determine OS
@@ -49,9 +60,9 @@ if [ "$os_name" = "Darwin" ]; then
4960

5061
# Check if brew is installed
5162
if command -v brew >/dev/null 2>&1; then
52-
echo -e "\n✅︎🍺 Homebrew already installed."
63+
printf "\n✅︎🍺 Homebrew already installed.\n"
5364
else
54-
if prompt_default_yes "\n🍺 Homebrew is not installed. Install it?"; then
65+
if prompt_default_yes "\n🍺 Homebrew is not installed. Install it?\n"; then
5566
echo "🍺 Installing Homebrew."
5667
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
5768
else
@@ -62,9 +73,9 @@ if [ "$os_name" = "Darwin" ]; then
6273

6374
brew update
6475
if command -v git >/dev/null 2>&1; then
65-
echo -e "\n✅︎🍺 git already installed."
76+
printf "\n✅︎🍺 git already installed.\n"
6677
else
67-
if prompt_default_yes "\n🍺 git seems to be missing but we will need it; install git?"; then
78+
if prompt_default_yes "\n🍺 git seems to be missing but we will need it; install git?\n"; then
6879
brew install git
6980
else
7081
echo "❌ Cannot continue without git. Aborting."
@@ -82,24 +93,26 @@ elif [ "$os_name" = "Linux" ]; then
8293
distro=$( cat /etc/*-release | tr '[:upper:]' '[:lower:]' | grep -Poi '(debian|ubuntu|arch|fedora|opensuse)' | uniq | head -n 1 )
8394

8495
if [ "$distro" = "ubuntu" ]; then
85-
echo -e "\n🐧 Detected Ubuntu. Using apt to install dependencies."
86-
sudo apt install --assume-yes git clang curl libssl-dev protobuf-compiler
96+
printf "\n🐧 Detected Ubuntu. Using apt to install dependencies.\n"
97+
sudo apt -qq update
98+
sudo apt -qq install --assume-yes git clang curl libssl-dev protobuf-compiler
8799
elif [ "$distro" = "debian" ]; then
88-
echo -e "\n🐧 Detected Debian. Using apt to install dependencies."
89-
sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler
100+
printf "\n🐧 Detected Debian. Using apt to install dependencies.\n"
101+
sudo apt -qq update
102+
sudo apt -qq install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler
90103
elif [ "$distro" = "arch" ]; then
91-
echo -e "\n🐧 Detected Arch Linux. Using pacman to install dependencies."
104+
printf "\n🐧 Detected Arch Linux. Using pacman to install dependencies.\n"
92105
pacman -Syu --needed --noconfirm curl git clang make protobuf
93106
elif [ "$distro" = "fedora" ]; then
94-
echo -e "\n🐧 Detected Fedora. Using dnf to install dependencies."
107+
printf "\n🐧 Detected Fedora. Using dnf to install dependencies.\n"
95108
sudo dnf update
96109
sudo dnf install clang curl git openssl-devel make protobuf-compiler
97110
elif [ "$distro" = "opensuse" ]; then
98-
echo -e "\n🐧 Detected openSUSE. Using zypper to install dependencies."
111+
printf "\n🐧 Detected openSUSE. Using zypper to install dependencies.\n"
99112
sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf
100113
else
101-
if prompt "\n🐧 Unknown Linux distribution. Unable to install dependencies. Continue anyway?"; then
102-
echo -e "\n🐧 Proceeding with unknown linux distribution..."
114+
if prompt "\n🐧 Unknown Linux distribution. Unable to install dependencies. Continue anyway?\n"; then
115+
printf "\n🐧 Proceeding with unknown linux distribution...\n"
103116
else
104117
exit 1
105118
fi
@@ -111,7 +124,7 @@ fi
111124

112125
# Check if rust is installed
113126
if command -v rustc >/dev/null 2>&1; then
114-
echo -e "\n✅︎🦀 Rust already installed."
127+
printf "\n✅︎🦀 Rust already installed.\n"
115128
else
116129
if prompt_default_yes "\n🦀 Rust is not installed. Install it?"; then
117130
echo "🦀 Installing via rustup."
@@ -131,17 +144,34 @@ if prompt_default_yes "\n🦀 Setup the Rust environment (e.g. WASM support)?";
131144
rustup component add rust-src
132145
fi
133146

134-
if [ -d "minimal-template" ]; then
135-
echo -e "\n✅︎ minimal-template directory already exists. -> Entering."
136-
else
137-
echo -e "\n↓ Let's grab the minimal template from github."
138-
git clone https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template
147+
if ! prompt "\nWould you like to start with one of the templates?"; then
148+
echo "⚡ All done, the environment is ready for hacking."
149+
exit 0
150+
fi
151+
152+
while true; do
153+
printf "\nWhich template would you like to start with?\n"
154+
echo "1) minimal template"
155+
echo "2) parachain template"
156+
echo "3) solochain template"
157+
echo "q) cancel"
158+
read -p "#? " template
159+
case $template in
160+
[1]* ) clone_and_enter_template minimal; break;;
161+
[2]* ) clone_and_enter_template parachain; break;;
162+
[3]* ) clone_and_enter_template solochain; break;;
163+
[qQ]* ) echo "Canceling, not using a template."; exit 0;;
164+
* ) echo "Selection not recognized.";;
165+
esac
166+
done
167+
168+
if ! prompt_default_yes "\n⚙️ Let's compile the node? It might take a while."; then
169+
echo "⚡ Script finished, you can continue in the ${template}-template directory."
170+
exit 0
139171
fi
140-
cd minimal-template
141172

142-
echo -e "\n⚙️ Let's compile the node."
143173
cargo build --release
144174

145-
if prompt_default_yes "\n🚀 Everything ready to go, let's run the node?"; then
175+
if prompt_default_yes "\n🚀 Everything ready to go, let's run the node?\n"; then
146176
cargo run --release -- --dev
147177
fi

0 commit comments

Comments
 (0)