diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index fc94441c..657d1aaa 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -1073,7 +1073,7 @@ function mesh_web_server { chroot "$rootdir" apt-get -y install nginx - if [ ! -d /etc/nginx ]; then + if [ ! -d $rootdir/etc/nginx ]; then echo $'Unable to install web server' exit 346825 fi diff --git a/src/freedombone-image-mesh b/src/freedombone-image-mesh index 8366f7e1..a06a0869 100755 --- a/src/freedombone-image-mesh +++ b/src/freedombone-image-mesh @@ -302,6 +302,71 @@ function configure_zeronet_forum { echo $'Update of ZeroNet Forum completed' >> $INSTALL_LOG } +function configure_zeronet_id { + echo $'Updating ZeroID' >> $INSTALL_LOG + + cd /opt/zeronet + python zeronet.py --batch siteCreate 2> /opt/zeronet/zeroid.txt + if [ ! -f /opt/zeronet/zeroid.txt ]; then + echo $'Unable to create ZeroID' >> $INSTALL_LOG + exit 47962 + fi + zeroid_address=$(cat zeroid.txt | grep "Site address" | awk -F ':' '{print $2}') + zeroid_private_key=$(cat zeroid.txt | grep "Site private key" | awk -F ':' '{print $2}') + ZERONET_ID_ADDRESS=${zeroid_address//[[:blank:]]/} + ZERONET_ID_PRIVATE_KEY=${zeroid_private_key//[[:blank:]]/} + + if [ ${#ZERONET_ID_ADDRESS} -lt 20 ]; then + echo $"Address: $ZERONET_ID_ADDRESS" >> $INSTALL_LOG + echo $"Public key: $ZERONET_ID_PRIVATE_KEY" >> $INSTALL_LOG + echo $'Unable to create ZeroID address' >> $INSTALL_LOG + exit 76352 + fi + + if [ ${#ZERONET_ID_PRIVATE_KEY} -lt 20 ]; then + echo $"Address: $ZERONET_ID_ADDRESS" >> $INSTALL_LOG + echo $"Public key: $ZERONET_ID_PRIVATE_KEY" >> $INSTALL_LOG + echo $'Unable to create ZeroID private key' >> $INSTALL_LOG + exit 87356 + fi + + if [ ! -d "/opt/zeronet/data/$ZERONET_ID_ADDRESS" ]; then + echo $"Unable to find site directory: /opt/zeronet/data/$ZERONET_ID_ADDRESS" >> $INSTALL_LOG + exit 378434 + fi + + echo $"ZeroID address: $ZERONET_ID_ADDRESS" + echo $"ZeroID private key: $ZERONET_ID_PRIVATE_KEY" + cp -r /opt/zeronet/ZeroID/* /opt/zeronet/data/$ZERONET_ID_ADDRESS + # TODO + sed -i "s///g" /opt/zeronet/data/$ZERONET_ID_ADDRESS/content.json + python zeronet.py siteSign $ZERONET_ID_ADDRESS $ZERONET_ID_PRIVATE_KEY --inner_path data/users/content.json + + # Add an avahi service + echo '' > /tmp/zeronet-id.service + echo '' >> /tmp/zeronet-id.service + echo '' >> /tmp/zeronet-id.service + echo ' %h ZeroID' >> /tmp/zeronet-id.service + echo ' ' >> /tmp/zeronet-id.service + echo ' _zeronet._udp' >> /tmp/zeronet-id.service + echo " $ZERONET_PORT" >> /tmp/zeronet-id.service + echo " $ZERONET_URL/$ZERONET_ID_ADDRESS" >> /tmp/zeronet-id.service + echo ' ' >> /tmp/zeronet-id.service + echo '' >> /tmp/zeronet-id.service + sudo cp /tmp/zeronet-id.service /etc/avahi/services/zeronet-id.service + + if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then + mkdir -p /home/$MY_USERNAME/.config/zeronet + chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config + fi + echo "$ZERONET_URL/$ZERONET_ID_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/myzeroid + + sed -i "s|ZeroID address.*|ZeroID address: $ZERONET_ID_ADDRESS|g" /home/$MY_USERNAME/README + sed -i "s|ZeroID private key.*|ZeroID private key: $ZERONET_ID_PRIVATE_KEY|g" /home/$MY_USERNAME/README + + echo $'Update of ZeroID completed' >> $INSTALL_LOG +} + function configure_toxcore { echo $'Configuring toxcore' >> $INSTALL_LOG @@ -382,6 +447,7 @@ if [ -f /root/.initial_mesh_setup ]; then configure_zeronet_blog configure_zeronet_mail configure_zeronet_forum + configure_zeronet_id configure_toxcore configure_zeronet disable_password_logins