ZeroNet Blogs

Static ZeroNet blogs mirror

Delete Unwanted Sites (zites)

- Posted in muja's blog by with comments

Bash script to delete sites with user interaction.


Script on NullPaste

#!/bin/bash

for i in 1*; do
    echo ""
    grep --color=auto "description" $i/content.json
    grep --color=auto "title" $i/content.json
    try="True"
    while [ "$try" = "True" ]; do
        echo ""
        read -p "Delete? (yes/no) " rd_cln
        if [ -z "$rd_cln" ]; then
            rd_cln="no"
        fi
        if [ "$rd_cln" = "yes" ] || [ "$rd_cln" = "y" ]; then
            echo "Deleted"
            rm -rf $i
            try="False"
        elif [ "$rd_cln" = "no" ] || [ "$rd_cln" = "n" ]; then
            try="False"
        elif [ "$rd_cln" = "ls" ]; then
            ls -lAh $i
            try="True"            
        fi
    done
done

ZeroVerse support

- Posted in muja's blog by with comments

This blog now accepts certificates created by the ZeroVerse authority.

If this feature is not working, try cleaning your cache or use CTRL + SHIFT + R on the js/all.js file.

You're reading a blog post. You see an interesting link. You click it. The page changes, you go back but now you're at the top of the post.

Not anymore.


With the code that I will share with you, refreshing a page or going back to it will take you to the last spot you left it.

This feature came from a commit from ZeroTalk. (see it on NullPaste)

Edit your js/all.js file.

Search for this.next_message_id = 1; and add this.history_state = {}; in the line after it.

Search for return this.cmd("innerReady"); and replace it with:

this.cmd("innerReady");
      window.addEventListener("beforeunload", (function(_this) {
        return function(e) {
          _this.log("save scrollTop", window.pageYOffset);
          _this.history_state["scrollTop"] = window.pageYOffset;
          return _this.cmd("wrapperReplaceState", [_this.history_state, null]);
        };
      })(this));
      return this.cmd("wrapperGetState", [], (function(_this) {
        return function(state) {
          if (state != null) {
            _this.history_state = state;
          }
          _this.log("restore scrollTop", state, window.pageYOffset);
          if (window.pageYOffset === 0 && state) {
            return window.scroll(window.pageXOffset, state.scrollTop);
          }
        };
      })(this));

If this feature is not working, try cleaning your cache or use CTRL + SHIFT + R on the js/all.js file.

ZeroCommands

- Posted in muja's blog by with comments

If you read my past posts, you'll see that I'm a huge fan of aliases.

On this post I will, over time, publish all zeronet-related aliases that I can make.


Last update: 9 March, 2016.

  • Start ZeroNet: alias 0='gnome-terminal -x ~/code/zeronet/start.sh'

  • Your user: alias zuser='grep -s \"auth_user_name\" /path/to/zeronet/data/users.json'

  • Change your user: alias zch='~code/zeronet/changer.sh'

  • Go to ZeroNet folder: alias zerogo='cd /path/to/zeronet' or alias zg='cd /path/to/zeronet'

  • Go to data folder of ZeroNet: alias zerogodata='cd /path/to/zeronet/data' or alias zgd='cd /path/to/zeronet/data'

  • Sign site's content: alias zs='python zeronet.py siteSign'

  • Publish site: alias zp='python zeronet.py sitePublish'

  • Create site: alias zsc='python zeronet.py siteCreate'

  • Stop ZeroNet: alias zstop='~/code/zeronet/stop.sh'

You've been reading about this encryption thing, but what can you use it for?

I've seen that lots of people want to know how to change their ZeroId, so I made a script that will encrypt your current user, decrypt your other user and then change your user. Sounds good?


If you use anything that's not Linux (or maybe Mac), then this won't work for you. You should try Linux, it's what cool people use this days ( :P ) and you don't need to uninstall your current operating system. A lot of people recommend Linux Mint for beginners.

This "tutorial" assumes that your ZeroNet client is not running and that you have two users.json files both registered with ZeroIds. Simply move your current file to another folder and a new one will be created when you start ZeroNet (or maybe even while running).

First thing you gotta do is get yourself some encryption keys.

A few notes before:

The majority of people [citation needed] (;P) advertise against RSA-4096 (that's the size of the key in bits) saying that it's unnecessary since you gain less and less security as your key size increases (see Diminishing returns). My take is that you can't have too much of a good thing (how naive). But read this to see why they say it's unnecessary.

Pro-tip: since we are going to use these keys for scripts, give it some simple, one word name, it'll help later.

So, when they ask you for your Real name, call it Scripts.

Run gpg --gen-key

Nice!

Now, before I give you the script, make a folder where you will save your encrypted ZeroIds. For example /home/muja/backups/zeronet/users or whatever works best for you. Just remember to put it on the script bellow.

Open a text editor and paste the second code-block (not changer.sh) on it.

changer.sh

#!/bin/bash

# Backup current user

mkdir -p /tmp/zeronet/users/$1 > /dev/null 2>&1
cp /path/to/zeronet/data/users.json /tmp/zeronet/users/$1/users.json
cp /path/to/zeronet/data/sites.json /tmp/zeronet/users/$1/sites.json
cd /tmp/zeronet/users
zip -rq $1.zip $1/ > /dev/null 2>&1
gpg --yes -r Scripts -o /home/muja/backups/zeronet/users/$1.zip.asc -aes /tmp/zeronet/users/$1.zip
rm -f $1.zip
rm -rf $1/

# Change user

gpg -o /tmp/zeronet/users/$2.zip /home/muja/backups/zeronet/users/$2.zip.asc
unzip $2.zip  > /dev/null 2>&1
cp $2/users.json /path/to/zeronet/data/users.json
rm -f $2.zip
rm -rf $2/

After you make the necessary changes (the path to your zeronet folder, the backup folder, your key name...) give the script permissions to run, like so:

chmod 755 changer.sh

Get an alias to call your script, like so:

echo "alias zch='/path/changer.sh'" >> ~/.bashrc

Run the script (zch muja muja). Change muja to your user (yes, two times).

Cool, your user (and your sites list) should be encrypted on /home/muja/backups/zeronet/users/muja.zip.asc.

Now put your other user on /path/to/zeronet/data/users.json and run the command again, but this time calling your other user:

zch othermuja muja

The first is your current user and the second is the one you want to change to.

This script is a lot simpler than it might look. If anyone tried doing this and it did not work, make sure you changed these things:

/path/to/zeronet # Path to your zeronet folder
Scripts # Your Real name on your key
/home/muja/backups/zeronet/users #The place to save your users

There's also the chance that I, while adapting this code for publishing, may have made some errors. So feel free to comment bellow or send me a ZeroMail.

It's very unlikely that someone will do this since it's such a niche thing, I just wanted to publish it anyway :)

Using .bit domains

- Posted in muja's blog by with comments

If you got a .bit doman, that's cool!


Now you need to add "domain": "yourAdress.bit", to your content.json file.

Here's an example from ZeroBlog's content.json:

 "description": "Blogging platform Demo",
 "domain": "Blog.ZeroNetwork.bit",

Now clicking on your site from ZeroHello will open your .bit doman.

Stopping ZeroNet with a script

- Posted in muja's blog by with comments

Because sometimes CTRL + C is not the best option.


This will only work if you have something like zero.sh already.

As usual you can save some typing by using an alias, like so:

echo "alias zstop='/path/stop.sh'" >> ~/.bashrc

And here's the script:

stop.sh

#!/bin/bash

cd ~code/zeronet
zeroPID=$( pgrep zero.sh )

if [ $zeroPID ]
then
    kill -INT -$zeroPID
    echo "ZeroNet has stopped"
else
    echo "ZeroNet is not running"
fi

For some reason pgrep doesn't work with absolute paths, hence the cd.

Starting ZeroNet with a script

- Posted in muja's blog by with comments

This script will minimize the terminal, pull the latest commits and then start the client.


To make it work even better, call the script in a new terminal. Here's an alias, but keep in mind that I use the gnome terminal so you might need to adapt this to the one you use.

echo "alias zero='gnome-terminal -x /path/zero.sh'" >> ~/.bashrc

Now that you have an easy and nice way of calling your script, let's create the actual script, here it is:

zero.sh (0.0.4)

#!/bin/bash

sleep 1
minWindow() { xdotool getactivewindow windowminimize
}
cd /path/to/zeronet

if [ $1 ]; then
    if [ $1 == "disable" ]; then
    minWindow
    python zeronet.py --tor $1
    elif [ $1 == "no-git" ]; then
    minWindow
    python zeronet.py --tor always
    else
    echo "Updating repository..."
    git pull origin master
    echo " "
    minWindow
    python zeronet.py --tor $1
    fi
else
echo "Updating repository..."
git pull origin master
echo " "
minWindow
python zeronet.py --tor always
fi

That's it.