# Script to automate IPNS republication: input welcome

**URL:** <https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559>\
**Category:** Help\
**Created:** [June 1, 2017, 12:53pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559 "2017-06-01T12:53:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JayBrown](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jaybrown/32/107_2.png) [@JayBrown](https://discuss.ipfs.tech/u/JayBrown)\
**Post date:** [June 1, 2017, 12:53pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/1 "2017-06-01T12:53:15Z")

</div>

This was just a quickly hacked reply over in this thread by @raucoule1u :

> [@Mutability using IPNS, but multiple contributors](https://discuss.ipfs.tech/t/mutability-using-ipns-but-multiple-contributors/555/8):
>
> You could (if you’re on macOS) create a LaunchAgent that runs e.g. every 4 hours and automates the “republication”. See the script below, but I’m not sure if that’s all that’s needed (I haven’t tested it). If IPFS isn’t yet running, it would run ipfs daemon and wait 5 seconds before starting the repub loop; I guess that’s time enough. And you would need a text file $HOME/.ipns/ipns-pubs.txt, a path you can obviously change. In that text file you would need one line for each IPNS publication, eac…

But I’m adding the actual script here, so if you have improvements, please chime in. (Also linking to this thread from the original one.)

```auto
#!/bin/bash
IPFS=""
IPNS_LIST=$(cat "$HOME/.ipns/ipns-pubs.txt") # change path to ipns-pubs.txt to your liking, then add hashes & their publishing keys (use 'self' for default PeerID)
if [["$IPNS_LIST" == ""]] ; then
	echo "No hashes to republish."
	echo "Exiting."
	exit
fi
if [[$(ps aux | /usr/bin/grep "ipfs daemon" | grep -v "/usr/bin/grep ipfs daemon") == ""]] ; then
	echo "IPFS daemon not running. Starting now..."
	ipfs daemon &
	sleep 5
	IPFS="start"
else
	echo "IPFS daemon already running."
fi
while read -r LINE
do
	[["$LINE" == ""]] && continue
	IPFS_HASH=$(echo "$LINE" | awk '{print $1}')
	IPNS_KEY=$(echo "$LINE" | awk '{print $2}')
	[["$IPNS_KEY" == ""]] && continue
	echo "Now publishing $IPFS_HASH with $IPNS_KEY"
	if [["$IPNS_KEY" == "self"]] ; then
		ipfs name publish /ipfs/"$IPFS_HASH"
	else
		ipfs name publish --key="$IPNS_KEY" /ipfs/"$IPFS_HASH"
	fi
done < <(echo "$IPNS_LIST")
if [["$IPFS" == "start"]] ; then
	echo "Stopping IPFS daemon..."
	killall ipfs
fi
echo "Done."

```

---

<div class="post-metadata">

**Author:** ![Kubuxu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/kubuxu/32/17_2.png) [@Kubuxu](https://discuss.ipfs.tech/u/Kubuxu)\
**Post date:** [June 2, 2017, 7:40pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/2 "2017-06-02T19:40:38Z")

</div>

There is also WIP PR to go-ipfs that solves it: [https://github.com/ipfs/go-ipfs/pull/3951](https://github.com/ipfs/go-ipfs/pull/3951)

---

<div class="post-metadata">

**Author:** ![JayBrown](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jaybrown/32/107_2.png) [@JayBrown](https://discuss.ipfs.tech/u/JayBrown)\
**Post date:** [June 6, 2017, 5:07pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/3 "2017-06-06T17:07:38Z")

</div>

Good news regarding the PR.

PS: now also tested my script. Seems to work, but I’m glad it won’t be necessary anymore soon. 😉

---

<div class="post-metadata">

**Author:** ![raucoule1u](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/raucoule1u/32/425_2.png) [@raucoule1u](https://discuss.ipfs.tech/u/raucoule1u)\
**Post date:** [June 7, 2017, 7:10am UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/4 "2017-06-07T07:10:59Z")

</div>

Does it mean that the “auto-republication” for generated keys is now embedded in go-ipfs ?  
And we don’t have to deal with it manually ?

---

<div class="post-metadata">

**Author:** ![JayBrown](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jaybrown/32/107_2.png) [@JayBrown](https://discuss.ipfs.tech/u/JayBrown)\
**Post date:** [June 7, 2017, 8:11am UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/5 "2017-06-07T08:11:29Z")

</div>

That’s how I understand it, yes. Not sure, when it’ll be released.

---

<div class="post-metadata">

**Author:** ![raucoule1u](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/raucoule1u/32/425_2.png) [@raucoule1u](https://discuss.ipfs.tech/u/raucoule1u)\
**Post date:** [June 7, 2017, 8:54am UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/6 "2017-06-07T08:54:54Z")

</div>

Ok great, hope it will be soon ! 😁

---

<div class="post-metadata">

**Author:** ![Kubuxu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/kubuxu/32/17_2.png) [@Kubuxu](https://discuss.ipfs.tech/u/Kubuxu)\
**Post date:** [June 7, 2017, 1:40pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/7 "2017-06-07T13:40:51Z")

</div>

It is still Work In Progress but should be there if not in the next version then in the one after it.

---

<div class="post-metadata">

**Author:** ![koalalorenzo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/koalalorenzo/32/745_2.png) [@koalalorenzo](https://discuss.ipfs.tech/u/koalalorenzo)\
**Post date:** [June 7, 2017, 11:53pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/8 "2017-06-07T23:53:57Z")

</div>

I hope it is going to be on the next version !

---

<div class="post-metadata">

**Author:** ![JayBrown](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jaybrown/32/107_2.png) [@JayBrown](https://discuss.ipfs.tech/u/JayBrown)\
**Post date:** [June 28, 2017, 5:28pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/9 "2017-06-28T17:28:33Z")

</div>

It is. v0.4.10 will add republish for keys other than self. 👏 Among loads of other additions & enhancements. Wow! 🎉

> <https://github.com/ipfs/go-ipfs/blob/master/CHANGELOG.md>

---

<div class="post-metadata">

**Author:** ![koalalorenzo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/koalalorenzo/32/745_2.png) [@koalalorenzo](https://discuss.ipfs.tech/u/koalalorenzo)\
**Post date:** [June 28, 2017, 7:15pm UTC](https://discuss.ipfs.tech/t/script-to-automate-ipns-republication-input-welcome/559/10 "2017-06-28T19:15:44Z")

</div>

This is a great news! 🙂
