Skip to content
Permalink
Browse files

update deb package facility (#10)

* optimize Makefile

* fix typo issue

* update deb package facility

Signed-off-by: Yi Wang <wangyi@storswift.com>
  • Loading branch information...
yeewang authored and coder-lb committed Jan 24, 2019
1 parent 18480d2 commit 3f7aa177dc56444d732b911667f32879038ae84a
@@ -13,7 +13,7 @@ The typical IPFS peer is a resource hunger program. If you install IPFS daemon t

The project distils from the IPFS Cluster, but it will have many differences with the IPFS Cluster.

Elastos Hive Cluster maintains a big IPFS pinset for sharing. It can serve numerous virtual IPFS peers with only one IPFS peer instance running.
Elastos Hive Cluster maintains a big IPFS pinset for sharing. It can serve numerous virtual IPFS peers with only one IPFS peer instance running.

Hive Cluster is not only a pinset manager but also a backend for multiple IPFS clients.

@@ -111,7 +111,7 @@ Note that when the ipfs daemon is running locally on its default ports, the buil

#### Building Debian package

For Linux Debian based systems. This project can generate a deb package for to distribute conveniently.
For Linux Debian based systems. This project can generate a deb package for to distribute conveniently.

Please make sure that the IPFS and IPFS-Cluster projects were built and
the binraries (ipfs, ipfs-cluster-service, ipfs-cluster-ctl) had been generated under the directory `$GOPATH/bin`.
@@ -14,8 +14,7 @@ pack:
@dpkg-deb --build ${TOP_DIR}/deb "${TOP_DIR}/${TARGET}"

clean:
@echo "Clean up ..."
[ -d "${BIN_DIR}" ] && rm -rf "${BIN_DIR}"
[ -f "${TOP_DIR}/${TARGET}" ] && rm -f "${TOP_DIR}/${TARGET}"
@rm -rf "${BIN_DIR}"
@rm -f "${TOP_DIR}/${TARGET}"

.PHONY: all pack
@@ -1,18 +1,41 @@
#!/bin/bash

USER=hive
pkill ipfs
ls /home/$USER/
su - $USER -c "export `cat /home/$USER/ipfs.conf`;/usr/local/bin/ipfs init"

export IPFS_PATH=/var/lib/hive/ipfs
export IPFS_CLUSTER_PATH=/var/lib/hive/ipfs-cluster

NOW=$(date +%Y%m%d_%H%M)

chown --reference=/usr/bin /usr/local/bin/ipfs
chown --reference=/usr/bin /usr/local/bin/ipfs-cluster-service
chown --reference=/usr/bin /usr/local/bin/ipfs-cluster-ctl

if [ -d ${IPFS_PATH} ]; then
echo "Move previous ipfs repo to ${IPFS_PATH}.${NOW}."
mv ${IPFS_PATH}{,.${NOW}}
else
mkdir -p ${IPFS_PATH}
fi

/usr/local/bin/ipfs init
sleep 2
su - $USER -c "export `cat /home/$USER/ipfs-cluster.conf`;/usr/local/bin/ipfs-cluster-service init"

if [ -d ${IPFS_CLUSTER_PATH} ]; then
echo "Move previous ipfs-cluster configuration to ${IPFS_CLUSTER_PATH}.${NOW}."
mv ${IPFS_CLUSTER_PATH}{,.${NOW}}
else
mkdir -p ${IPFS_CLUSTER_PATH}
fi

/usr/local/bin/ipfs-cluster-service init
sleep 2

path=`cat /home/$USER/ipfs-cluster.conf | awk -F '=' '{print $2}'`
sed -i 's#127.0.0.1/tcp/909#0.0.0.0/tcp/909#g' $path/service.json
sed -i 's#127.0.0.1/tcp/9094#0.0.0.0/tcp/9094#g; s#127.0.0.1/tcp/9095#0.0.0.0/tcp/9095#g;' ${IPFS_CLUSTER_PATH}/service.json

chown -R ${USER}:${USER} /var/lib/hive

systemctl enable ipfs
systemctl enable ipfs-cluster
systemctl start ipfs
systemctl start ipfs-cluster

@@ -1,9 +1,8 @@
#!/bin/bash

pkill ipfs
rm /home/hive/ipfs.conf -rf
rm /home/hive/ipfs-cluster.conf -rf
rm /etc/systemd/system/multi-user.target.wants/ipfs* -f
systemctl stop ipfs
systemctl stop ipfs-cluster
find /etc/systemd/system -type f -name "ipfs.service" -o -name "ipfs-cluster.service" -exec rm -f {} \;
systemctl daemon-reload
sed -i '/hive/d' /etc/passwd
sed -i '/hive/d' /etc/group

@@ -1,40 +1,22 @@
#!/bin/bash

USER=hive
ipfs_path=/home/$USER/.ipfs
ipfs_cluster_path=/home/$USER/.ipfs-cluster
config_path=/etc/hive
ipfs_path=/var/lib/hive/ipfs
ipfs_cluster_path=/var/lib/hive/ipfs-cluster

cat /etc/passwd | awk -F ':' '{print $1}' | grep $USER 1>/dev/null
if [ $? == 1 ];then
/usr/sbin/useradd -m -s /bin/bash -p IkT3yq7CH8hyk $USER 1>/dev/null 2>/dev/null
cat /etc/passwd | awk -F ':' '{print $1}' | grep -q $USER 1>/dev/null
if [ $? -ne 0 ]; then
/usr/sbin/useradd -d /var/lib/hive -s /usr/sbin/nologin $USER 1>/dev/null 2>/dev/null
fi

[ -d ${config_path} ] || mkdir -p ${config_path}
[ -f ${config_path}/hive.conf ] && mv ${config_path}/hive.conf{,.old}

echo "#############################################"
echo "Please set ipfs repo(IPFS_PATH):"
read path
if [ -n "$path" ]; then
mkdir -p $path
IPFS_PATH=$path
else
echo "You did not set the IFPS_PATT,then set the IPFS_PATH to the default location:/home/hive/.ipfs"
mkdir -p $ipfs_path
IPFS_PATH=$ipfs_path
fi
chown -R $USER:$USER $IPFS_PATH
echo "IPFS_PATH=$IPFS_PATH" >/home/$USER/ipfs.conf

echo "#############################################"
echo "Please set ipfs-cluster repo(IPFS_CLUSTER_PATH):"
read cluster_path
if [ -n "$cluster_path" ]; then
mkdir -p $cluster_path
IPFS_CLUSTER_PATH=$cluster_path
else
echo "You did not set the IFPS_CLUSTER_PATT,then set the IPFS_CLUSTER_PATH to the default location:/home/hive/.ipfs-cluster"
mkdir -p $ipfs_cluster_path
IPFS_CLUSTER_PATH=$ipfs_cluster_path
fi
chown -R $USER:$USER $IPFS_CLUSTER_PATH
echo "IPFS_CLUSTER_PATH=$IPFS_CLUSTER_PATH" >/home/$USER/ipfs-cluster.conf
echo "Set the IPFS_PATH to the location: ${ipfs_path}"
echo "Set the IPFS_CLUSTER_PATH to the location: ${ipfs_cluster_path}"

cat << EOF > ${config_path}/hive.conf
IPFS_PATH=${ipfs_path}
IPFS_CLUSTER_PATH=${ipfs_cluster_path}
EOF
@@ -1,14 +1,14 @@
[Unit]
Description=Elastos Hive IPFS-Cluster Daemon
After=network-online.target ipfs.service
After=network-online.target
Wants=network-online.target

[Service]
User=hive
Group=hive

Type=forking
ExecStart=/home/hive/ipfs-cluster.sh
EnvironmentFile=/etc/hive/hive.conf
Type=simple
ExecStart=/usr/local/bin/ipfs-cluster-service daemon
Restart=always

[Install]
@@ -6,9 +6,9 @@ Wants=network-online.target
[Service]
User=hive
Group=hive

Type=forking
ExecStart=/home/hive/ipfs.sh
EnvironmentFile=/etc/hive/hive.conf
Type=simple
ExecStart=/usr/local/bin/ipfs daemon
Restart=always

[Install]

This file was deleted.

This file was deleted.

0 comments on commit 3f7aa17

Please sign in to comment.
You can’t perform that action at this time.