mirror of
https://github.com/claudiobizzotto/ipfs-rpi.git
synced 2021-08-26 23:43:50 +03:00
issues/9 (#10)
* run OS services as "pi" user * Add "--migrate" flag when starting daemon * Update README
This commit is contained in:
30
README.md
30
README.md
@@ -1,5 +1,4 @@
|
||||
IPFS RPi
|
||||
========
|
||||
# IPFS RPi
|
||||
|
||||
A bare bones [IPFS](https://ipfs.io) installer for the Raspberry Pi and other ARM-based devices.
|
||||
|
||||
@@ -11,10 +10,10 @@ operating systems will default to the `pi` user, whereas on the Orange Pi that's
|
||||
From any local directory, clone or download this repo, `cd` into it and run the installer:
|
||||
|
||||
```SHELL
|
||||
$ ./install
|
||||
./install
|
||||
```
|
||||
|
||||
**Notes**
|
||||
### Notes
|
||||
|
||||
* Do **not** execute the installation script with `sudo`
|
||||
* You'll need root privileges to run the installer. The default OS user (`pi`, `orangepi` etc.) does so by default
|
||||
@@ -25,22 +24,16 @@ $ ./install
|
||||
You can specify a version for IPFS (eg.: `v0.4.11`):
|
||||
|
||||
```SHELL
|
||||
$ ./install v0.4.11
|
||||
./install v0.4.11
|
||||
```
|
||||
|
||||
## IPFS usage
|
||||
|
||||
You can find a lot of information on how to use IPFS on the [official website](https://ipfs.io/docs/getting-started/).
|
||||
If you just want to test whether the installation was successful or not, you can start by _checking out_ an IPFS object:
|
||||
If you just want to test whether the installation was successful or not, you can list your node's peers:
|
||||
|
||||
```SHELL
|
||||
$ ipfs cat /ipfs/QmRoyYykmw7XUsifRqkR7v6ezKuqhmvoQuukPGR1aQKRZh
|
||||
```
|
||||
|
||||
To confirm that your node is connected to the IPFS swarm (aka is online), you can list your node's peers:
|
||||
|
||||
```SHELL
|
||||
$ ipfs swarm peers
|
||||
ipfs swarm peers
|
||||
```
|
||||
|
||||
## IPFS daemon
|
||||
@@ -52,13 +45,13 @@ operating system's init system directly.
|
||||
For `systemd` (Raspbian Stretch, Ubuntu 15.04 and newer, CentOS 7 and newer), you can use:
|
||||
|
||||
```SHELL
|
||||
$ sudo systemctl {start|status|stop} ipfs-daemon.service
|
||||
sudo systemctl {start|status|stop} ipfs-daemon.service
|
||||
```
|
||||
|
||||
For `upstart` (Ubuntu 9.10 to Ubuntu 14.10, Centos 6), you can use:
|
||||
|
||||
```SHELL
|
||||
$ sudo service ipfs-daemon {start|status|stop}
|
||||
sudo service ipfs-daemon {start|status|stop}
|
||||
```
|
||||
|
||||
## Uninstallation
|
||||
@@ -66,9 +59,13 @@ $ sudo service ipfs-daemon {start|status|stop}
|
||||
In order to uninstall IPFS, just execute the uninstaller and follow the uninstallation steps:
|
||||
|
||||
```SHELL
|
||||
$ ./uninstall
|
||||
./uninstall
|
||||
```
|
||||
|
||||
## Upgrade
|
||||
|
||||
If you want to upgrade to a newer version, start by uninstalling IPFS, but make sure you keep the IPFS data directory (`~/.ipfs`). Then, run the installer with the specific version you want to install. Eg.: `./install v0.4.17`.
|
||||
|
||||
## Support matrix
|
||||
|
||||
| SBC/ARM device | Raspbian Stretch | Ubuntu 14.04 |
|
||||
@@ -84,4 +81,3 @@ $ ./uninstall
|
||||
* for bug reports, open a new issue
|
||||
* for code patches, open a pull request against the `development` branch
|
||||
* for bugs specific to IPFS, please refer to the [official channel](https://discuss.ipfs.io)
|
||||
|
||||
|
||||
16
install
16
install
@@ -28,7 +28,7 @@ ipfs_version=${1-"v0.4.13"}
|
||||
echo ">>> Installing IPFS version $ipfs_version"
|
||||
|
||||
tar_gz_destination=/tmp/go-ipfs_${ipfs_version}_${ipfs_arch}.tar.gz
|
||||
[ ! -f $tar_gz_destination ] && sudo wget "https://dist.ipfs.io/go-ipfs/${ipfs_version}/go-ipfs_${ipfs_version}_${ipfs_arch}.tar.gz" -O $tar_gz_destination
|
||||
sudo wget "https://dist.ipfs.io/go-ipfs/${ipfs_version}/go-ipfs_${ipfs_version}_${ipfs_arch}.tar.gz" -O $tar_gz_destination
|
||||
|
||||
if [ ! -f $tar_gz_destination ]; then
|
||||
echo ">>> Failed to download IPFS"
|
||||
@@ -47,18 +47,23 @@ sudo chmod 755 $ipfs_destination
|
||||
# Install and enable bring-up configurations for IPFS daemon
|
||||
init_system=$(get_init_system)
|
||||
ipfs_path=$HOME/.ipfs
|
||||
ipfs_user=pi
|
||||
ipfs_group=pi
|
||||
|
||||
if [ $init_system == "systemd" ]; then
|
||||
cat ./templates/ipfs-daemon.service.tpl | sed \
|
||||
"s|{{ipfs_path}}|${ipfs_path}|g" | \
|
||||
cat ./templates/ipfs-daemon.service.tpl | \
|
||||
sed "s|{{ipfs_path}}|${ipfs_path}|g" | \
|
||||
sed "s|{{ipfs_user}}|${ipfs_user}|g" | \
|
||||
sed "s|{{ipfs_group}}|${ipfs_group}|g" | \
|
||||
sudo tee /lib/systemd/system/ipfs-daemon.service > /dev/null
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ipfs-daemon
|
||||
sudo systemctl start ipfs-daemon.service
|
||||
elif [ $init_system == "upstart" ]; then
|
||||
cat ./templates/ipfs-daemon.conf.tpl | sed \
|
||||
"s|{{ipfs_path}}|${ipfs_path}|g" | \
|
||||
cat ./templates/ipfs-daemon.conf.tpl | \
|
||||
sed "s|{{ipfs_path}}|${ipfs_path}|g" | \
|
||||
sed "s|{{ipfs_user}}|${ipfs_user}|g" | \
|
||||
sudo tee /etc/init/ipfs-daemon.conf > /dev/null
|
||||
|
||||
sudo initctl reload-configuration
|
||||
@@ -68,4 +73,3 @@ else
|
||||
fi
|
||||
|
||||
echo ">>> All done."
|
||||
|
||||
|
||||
@@ -16,4 +16,3 @@ function get_init_system() {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@ stop on runlevel [!2345]
|
||||
|
||||
script
|
||||
echo $$ > /var/run/ipfs-daemon.pid
|
||||
exec /usr/local/bin/ipfs daemon
|
||||
exec su -s /bin/sh -c "/usr/local/bin/ipfs daemon --migrate" {{ipfs_user}}
|
||||
end script
|
||||
|
||||
pre-stop script
|
||||
rm /var/run/ipfs-daemon.pid
|
||||
end script
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ Wants=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User={{ipfs_user}}
|
||||
Group={{ipfs_group}}
|
||||
Type=simple
|
||||
Environment=IPFS_PATH={{ipfs_path}}
|
||||
ExecStart=/usr/local/bin/ipfs daemon
|
||||
ExecStart=/usr/local/bin/ipfs daemon --migrate
|
||||
ExecStop=/usr/bin/pkill -f ipfs
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
|
||||
15
uninstall
15
uninstall
@@ -31,11 +31,11 @@ if [ $init_system == "systemd" ]; then
|
||||
echo ">>> Failed to stop IPFS"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
sudo systemctl disable ipfs-daemon 2>/dev/null 1>&2
|
||||
sudo rm -f /lib/systemd/system/ipfs-daemon.service
|
||||
sudo systemctl daemon-reload
|
||||
fi
|
||||
|
||||
sudo systemctl disable ipfs-daemon 2>/dev/null 1>&2
|
||||
sudo rm -f /lib/systemd/system/ipfs-daemon.service
|
||||
sudo systemctl daemon-reload
|
||||
elif [ $init_system == "upstart" ]; then
|
||||
sudo service ipfs-daemon status 2>/dev/null 1>&2
|
||||
|
||||
@@ -47,10 +47,10 @@ elif [ $init_system == "upstart" ]; then
|
||||
echo ">>> Failed to stop IPFS"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
sudo rm -f /etc/init/ipfs-daemon.conf
|
||||
sudo initctl reload-configuration
|
||||
fi
|
||||
|
||||
sudo rm -f /etc/init/ipfs-daemon.conf
|
||||
sudo initctl reload-configuration
|
||||
fi
|
||||
|
||||
sudo rm -rf /usr/local/bin/ipfs
|
||||
@@ -71,4 +71,3 @@ if [ -d $ipfs_dir ]; then
|
||||
fi
|
||||
|
||||
echo ">>> All done."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user