I’ve updated my script to create nodes as services on Linux systems utilizing systemd. Note that the directories it requests the paths for have to have open to the world permissions (777) and the safenode binary needs to already be available in /usr/local/bin.
It’s flagging me as behind a NAT, which is the first time I’ve had this issue on my VPSs, so I guess I’m out for this test.
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run using sudo"
exit
fi
[ -f /usr/local/bin/safenode ] || { echo "Error: Please make sure the safenode executable is in /usr/local/bin"; exit 1;}
read -p "Enter the desired number of nodes: " nodenum
re='^[0-9]+$'
if ! [[ $nodenum =~ $re ]] ; then
echo "Error: Not a valid integer" >&2; exit 1
fi
if [[ $nodenum < 1 ]] ; then
echo "Error: A number greater than 1 must be entered"
fi
echo ""
echo "Directories will be created for the Safe data and logs."
read -p "Enter the desired parent directory for Safe data: " rootdir
read -p "Enter the desired parent directory for Safe logs: " logdir
echo "$nodenum Safe nodes will be created."
read -p "Continue (Y/N) " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
if ! [[ $(getent group safenode) ]]; then
groupadd -g 10500 safenode
fi
if ! [[ $(getent passwd safenode) ]]; then
useradd -u 10500 -g safenode -c "SafeNode User" -M safenode
usermod -L safenode
fi
if read -a rootVals < <(stat -Lc "%U %G %A" $rootdir) && (
( [ "$rootVals" == "safenode" ] && [ "${rootVals[2]:2:1}" == "w" ] ) ||
( [ "${rootVals[2]:8:1}" == "w" ] ) ||
( [ "${rootVals[2]:5:1}" == "w" ] && (
gMember=($(groups safenode)) &&
[[ "${gMember[*]:2}" =~ ^(.* |)${rootVals[1]}( .*|)$ ]]
) ) )
then
:
else
echo 'Safe user does not have access to the root directory. Before running again, make sure uid or gid 10500 has access to the directory. Cleaning up.'
userdel safenode
exit 1
fi
if read -a logVals < <(stat -Lc "%U %G %A" $logdir) && (
( [ "$logVals" == "safenode" ] && [ "${logVals[2]:2:1}" == "w" ] ) ||
( [ "${logVals[2]:8:1}" == "w" ] ) ||
( [ "${logVals[2]:5:1}" == "w" ] && (
gMember=($(groups safenode)) &&
[[ "${gMember[*]:2}" =~ ^(.* |)${logVals[1]}( .*|)$ ]]
) ) )
then
:
else
echo 'Safe user does not have access to the log directory. Before running again, make sure uid or gid 10500 has access to the directory. Cleaning up.'
userdel safenode
exit 1
fi
while [[ $nodenum > 0 ]]
do
cat >> /etc/systemd/system/safenode$nodenum.service << END
[Unit]
Description="Safe Node $nodenum"
[Service]
ExecStart=/usr/local/bin/safenode --root-dir=$rootdir/safenode$nodenum --log-dir=$logdir/safenode$nodenum
User=safenode
Group=safenode
Environment="SAFE_PEERS=/ip4/142.93.33.47/tcp/43691/p2p/12D3KooWATuSWjt61DUoqhVmHXpfenMnqMoPmrhnREQkZ25xrDGQ,/ip4/165.227.231.8/tcp/43103/p2p/12D3KooWByBQokh2D8Y7ATzXVCzKGiN5g4L8GKXBmBoZhAVeW4At,/ip4/165.232.106.150/tcp/41989/p2p/12D3KooWRYaapMU4i4zwNT3zQhcYPrkCd5QoHuLe7Z4PfGs3hQj5,/ip4/165.22.125.99/tcp/43473/p2p/12D3KooWAd3oubsP5yqU3gBnPw27zDqSZu4LW1F1hqkoojXBL7Rd,/ip4/165.22.119.173/tcp/38933/p2p/12D3KooWAvDMcv39DDsNd8kFSEMCc3cx5ye5VjYFhe43RRLw63rz"
Environment=SN_LOG=all
[Install]
WantedBy=multi-user.target
END
systemctl daemon-reload
systemctl enable safenode$nodenum
systemctl start safenode$nodenum
((nodenum--))
done
echo "Your Safe Node(s) should now be running."
echo "You can view their status using 'systemctl status safenode<number>'"
exit 0
Cleanup script.
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run using sudo"
exit
fi
echo "This will stop and remove all nodes from systemd."
read -p "Continue (Y/N) " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
nodesrem=true
node=1
while [ "$nodesrem" = "true" ]
do
systemctl list-unit-files |grep -q "^safenode$node.service" || nodesrem=false
if [ "$nodesrem" = "true" ]
then
((node++))
fi
done
((node--))
while [[ $node > 0 ]]
do
systemctl stop safenode$node
systemctl disable safenode$node
rm /etc/systemd/system/safenode$node.service
((node--))
done
systemctl daemon-reload
userdel safenode
echo "The nodes should be stopped and the user removed. You will need to manually remove the data and log directories if desired."
exit 0
buntu@safe-byres:~/safe/Mp3's/10mb$ safe files upload ./
Removed old logs from directory: "/tmp/safe-client"
Logging to directory: "/tmp/safe-client"
Current build's git commit hash: 0be2ef056215680b02ca8ec8be4388728bd0ce7c
🔗 Connected to the Network Storing file "New Order - The Best of New Order - 05 - Fine Time.MP3" of 3026944 bytes..
Did not store file "New Order - The Best of New Order - 05 - Fine Time.MP3" to all nodes in the close group! Network Error Outbound Error.
Storing file "John Farnham - Age of Reason - Beyond The Call.mp3" of 5664896 bytes..
Successfully stored file "John Farnham - Age of Reason - Beyond The Call.mp3" to 53879a747f552089b2b64c34b7306711769bd2ad8461eb75f1885c95fd8f7515
Storing file "Henry Rollins - A Rollins in the Wry - Men in Make Up.mp3" of 4412293 bytes..
Did not store file "Henry Rollins - A Rollins in the Wry - Men in Make Up.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Nickel Creek - Why Should The Fire Die - Scotch & Chocolate.mp3" of 5021696 bytes..
Did not store file "Nickel Creek - Why Should The Fire Die - Scotch & Chocolate.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Nirvana - From The Muddy Banks Of The Wishkah - Lithium.mp3" of 5048320 bytes..
Did not store file "Nirvana - From The Muddy Banks Of The Wishkah - Lithium.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Athlete - Vehicles & Animals - El Salvador.mp3" of 3323948 bytes..
Did not store file "Athlete - Vehicles & Animals - El Salvador.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Korn - Follow the Leader - It's On.mp3" of 4343808 bytes..
Did not store file "Korn - Follow the Leader - It's On.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Beastie Boys - Hello Nasty - And Me.mp3" of 2768896 bytes..
Successfully stored file "Beastie Boys - Hello Nasty - And Me.mp3" to ef8be932fb8fe486348e89cdac8b8346fa6b5b91d77df0ad4ba3dc8d7eb675f8
Storing file "Christina Aguilera - Stripped - Dirrty.mp3" of 4794368 bytes..
Did not store file "Christina Aguilera - Stripped - Dirrty.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Rage Against the Machine - Rage Against the Machine - Take The Power Back.mp3" of 5453824 bytes..
Did not store file "Rage Against the Machine - Rage Against the Machine - Take The Power Back.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Blur - Parklife - This Is A Low.mp3" of 5027840 bytes..
Did not store file "Blur - Parklife - This Is A Low.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Soulwax - As Heard On Radio Soulwax Pt.2 - Destiny's Child - Independent Woman Part 1 (A Capella); 10CC - Dreadlock Holiday.mp3" of 5720064 bytes..
Did not store file "Soulwax - As Heard On Radio Soulwax Pt.2 - Destiny's Child - Independent Woman Part 1 (A Capella); 10CC - Dreadlock Holiday.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Nanci Griffith - One Fair Summer Evening - Deadwood, South Dakota.mp3" of 1888256 bytes..
Successfully stored file "Nanci Griffith - One Fair Summer Evening - Deadwood, South Dakota.mp3" to 1e7799a69e1d3e5851895078979557aebd7ab3353449416bfb690328f47d56ea
Storing file "Johannes Heil - Freaks R Us - Magician.mp3" of 6838400 bytes..
Successfully stored file "Johannes Heil - Freaks R Us - Magician.mp3" to b8b52eceb2aeeb7286c2bd8b84f665af2e51a32d6e0f47a75d13165f05d6c968
Storing file "Rolling Stones - Let It Bleed - Gimme Shelter.mp3" of 6475776 bytes..
Did not store file "Rolling Stones - Let It Bleed - Gimme Shelter.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Nick Drake - Made to Love Magic - Tow the Line.mp3" of 2209792 bytes..
Successfully stored file "Nick Drake - Made to Love Magic - Tow the Line.mp3" to 33f91e7c168bdff496b255a89ebbd10bf16dd2ec87fac6ff9008ffd67c276f21
Storing file "Natasha Bedingfield - Unwritten - Frogs & Princes.mp3" of 3651584 bytes..
Did not store file "Natasha Bedingfield - Unwritten - Frogs & Princes.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Random Downloads - Downloads - Professional Widow [Armand Van Helden Remix].mp3" of 7794688 bytes..
Did not store file "Random Downloads - Downloads - Professional Widow [Armand Van Helden Remix].mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Fear Factory - Concrete - Piss Christ.mp3" of 3229696 bytes..
Did not store file "Fear Factory - Concrete - Piss Christ.mp3" to all nodes in the close group! Network Error Outbound Error.
Storing file "Starsailor - Love Is Here - Tie Up My Hands.mp3" of 5587323 bytes..
Did not store file "Starsailor - Love Is Here - Tie Up My Hands.mp3" to all nodes in the close group! Network Error Outbound Error.
virgin
ubuntu@safe-hamilton:~/safe/milonga_music$ safe files upload ./
Removed old logs from directory: "/tmp/safe-client"
Logging to directory: "/tmp/safe-client"
Current build's git commit hash: 0be2ef056215680b02ca8ec8be4388728bd0ce7c
🔗 Connected to the Network Storing file "(0060) Gotan Project - Vuelvo Al Sur live (edited).aac.flac.mp3" of 6215661 bytes..
Successfully stored file "(0060) Gotan Project - Vuelvo Al Sur live (edited).aac.flac.mp3" to a36897aec01f3f25d08e2f863fabe72fd20a785b5e42df3a9d264ec2137978ad
Storing file "(0072) Haris Alexiou - O Anthropos Mou.opus.mp3" of 5687493 bytes..
Successfully stored file "(0072) Haris Alexiou - O Anthropos Mou.opus.mp3" to 7844bc9a42736929b24cdba7583498e2b27e7d875a2276b578db41b20ffd75a3
Storing file "(0040) 028 . TROILO Anibal-1941-Milongueando en el 40.mp3.mp3" of 1662748 bytes..
Successfully stored file "(0040) 028 . TROILO Anibal-1941-Milongueando en el 40.mp3.mp3" to 9d6ecaad71519a60c19d1947e0d8e7874526654b331ea281a1756ae231a22661
Storing file "(0100) 066 . CORTINA.mp3.mp3" of 1088818 bytes..
Successfully stored file "(0100) 066 . CORTINA.mp3.mp3" to df06dc568014274a165a04a507741add21f1f85a2d034585d08de38436857691
Storing file "(0067) 053 . DARIENZO Juan-1967-La Trilla-Inst..mp3.mp3" of 1769205 bytes..
Successfully stored file "(0067) 053 . DARIENZO Juan-1967-La Trilla-Inst..mp3.mp3" to d37f16cf47ec1460b5af9a4b1585b02d07c0bdde4c655f473975ec1a014dd100
Storing file "(0051) 039 . LOMUTO Francisco-1933 - Puerto Nuevo-Fernando Diaz.mp3.mp3" of 3407306 bytes..
Successfully stored file "(0051) 039 . LOMUTO Francisco-1933 - Puerto Nuevo-Fernando Diaz.mp3.mp3" to c4ef6ca13d9cc247ca211088c75f47ebdf8cb7ab44a83cc9391eb322a83b0965
Storing file "(0012) 032 . VICTOR Tipica-1937-Milonga de los fortines-Mariano Balcarce.mp3.mp3" of 1306437 bytes..
Successfully stored file "(0012) 032 . VICTOR Tipica-1937-Milonga de los fortines-Mariano Balcarce.mp3.mp3" to 581f702d5707886319f46e0b3bf29b5b03649c7a8aebb2fb7925ba76684fe5d0
Storing file "(0013) (cortina1 - mixed) Shawn Lees Ping Pong Orchestra - Kiss The Sky.flac.mp3" of 602205 bytes..
Successfully stored file "(0013) (cortina1 - mixed) Shawn Lees Ping Pong Orchestra - Kiss The Sky.flac.mp3" to a23a256f33331365da33a1beb682a80f86732fe139a1b836fa3d84a56c25d7e4
Storing file "(0002) Haris Alexiou - Gia Ena Tango.opus.mp3" of 5903133 bytes..
Successfully stored file "(0002) Haris Alexiou - Gia Ena Tango.opus.mp3" to ddbcc3d62ea61f0c9922b6b410b17fa351fd2447ecb0e249c74ed7b7be5dfb88
Storing file "(0093) Bajofondo Tango Club - Montserrat (Orquesta Del Plata).ogg.mp3" of 6425805 bytes..
Successfully stored file "(0093) Bajofondo Tango Club - Montserrat (Orquesta Del Plata).ogg.mp3" to 4eab6ef572c6a44ff413f90746f579bba42c13b0aa92f4337b2d1c564f779c8a
Storing file "(0046) 016 . Para Ti Madre Vals.mp3.mp3" of 3820936 bytes..
Successfully stored file "(0046) 016 . Para Ti Madre Vals.mp3.mp3" to 029b27ff2374e3922d2eae1086872b73a30522521a99d4eb9288526e9bc0cf2f
Storing file "(0075) 043 . Tu Olvido Vals.mp3.mp3" of 1928569 bytes..
Successfully stored file "(0075) 043 . Tu Olvido Vals.mp3.mp3" to 8482f991d34516525f832090f567d3c7773a14ed2a66208b5fa273a907370278
Storing file "(0104) (cortina1 - mixed) Shawn Lees Ping Pong Orchestra - Kiss The Sky.flac.mp3" of 602205 bytes..
Successfully stored file "(0104) (cortina1 - mixed) Shawn Lees Ping Pong Orchestra - Kiss The Sky.flac.mp3" to a23a256f33331365da33a1beb682a80f86732fe139a1b836fa3d84a56c25d7e4
Storing file "(0030) Quartango - Androgyne.opus.mp3" of 5076525 bytes..
Successfully stored file "(0030) Quartango - Androgyne.opus.mp3" to 5e35ecad3390bd7b4f48105e0e3e3472172ecc4590069b7d86ed78ed8257c450
Storing file "(0015) Orsten - Fleur Blanche.ogg.mp3" of 4689997 bytes..
Successfully stored file "(0015) Orsten - Fleur Blanche.ogg.mp3" to 3892ed834526fafe17da9f3943eba0ed505d6261ffdf95f78116a901495b4972
Storing file "(0010) 029 . CORTINA.mp3.mp3" of 1019517 bytes..
Successfully stored file "(0010) 029 . CORTINA.mp3.mp3" to d535594e39aad63952f6f5b50760525fcbca15d02af3bf2af4fe882aab0fb696
Storing file "(0101) 067 . yo no se que han hecho tus ojos.mp3.mp3" of 2179646 bytes..
Successfully stored file "(0101) 067 . yo no se que han hecho tus ojos.mp3.mp3" to a0d06aaac04e003629c778c687d92947b41f6faa5b1e7d028ad422665a0d5278
Storing file "(0032) 056 . CORTINA.mp3.mp3" of 662204 bytes..
Successfully stored file "(0032) 056 . CORTINA.mp3.mp3" to d5573ef42223ed14954e6dc1ddec2ecdf1280b09fbe035b1032f5cf18b72ff3a
Storing file "(0070) (cortina2 - emotional) The Rolling Stones - Paint It, Black.mp3.mp3" of 729196 bytes..
Successfully stored file "(0070) (cortina2 - emotional) The Rolling Stones - Paint It, Black.mp3.mp3" to b12df721e1ac8fd2e0eb2819ce75f39ba35f6892343f1387e8d5661ccec6e8dc
Storing file "(0027) 023 . BIAGI Rodolfo-1941-Carillon de la merced-Jorge Ortiz.mp3.mp3" of 1982925 bytes..
Successfully stored file "(0027) 023 . BIAGI Rodolfo-1941-Carillon de la merced-Jorge Ortiz.mp3.mp3" to 320d30298c58ed29499c362e4163610555101566f039b2804ce41120923f8330
Storing file "(0034) 058 . CANARO Francisco-Reliquias Portenas-MILONGA.mp3.mp3" of 1972299 bytes..
Successfully stored file "(0034) 058 . CANARO Francisco-Reliquias Portenas-MILONGA.mp3.mp3" to c4b560577ca1be1b03bd3cbbdca73c17f246e7a091a2a131e27ba42a56ca7e8c
Storing file "(0107) Bebe - Siempre Me Quedara.mp3.mp3" of 4164969 bytes..
Successfully stored file "(0107) Bebe - Siempre Me Quedara.mp3.mp3" to a7b28c036b6bb1b52f0caf4fb17afadeacdf9533f66f9e8d85302bf6974555e7
Storing file "(0078) 061 . CORTINA.mp3.mp3" of 766748 bytes..
Successfully stored file "(0078) 061 . CORTINA.mp3.mp3" to 9ec19e83d0cd9933068afae7cade2b7647503a1868450d13c01e6a1dff4fe2a3
Storing file "(0025) 021 . BIAGI Rodolfo-1945-Tus labios me diran-Alberto Amor.mp3.mp3" of 1783854 bytes..
Successfully stored file "(0025) 021 . BIAGI Rodolfo-1945-Tus labios me diran-Alberto Amor.mp3.mp3" to b318138d0239323be04cc9d8e7a29dc45093116fddcd76f5053d2888e05f30cc
Storing file "(0048) 018 . Dos Corazones Vals.mp3.mp3" of 2684313 bytes..
Successfully stored file "(0048) 018 . Dos Corazones Vals.mp3.mp3" to 7ac8a0eb392967d48e8e305b4557d8ab527d30e54eacef78c10dda34b8dd8bc4
Storing file "(0045) 015 . CORTINA.mp3.mp3" of 997851 bytes..
Successfully stored file "(0045) 015 . CORTINA.mp3.mp3" to a82e710ab5b047f54a199b028ad86e1edb5ac2982ee41ac3568f825c50b083be
Storing file "(0014) Rupa & The April Fishes - Maintenant.opus.mp3" of 4287765 bytes..
Successfully stored file "(0014) Rupa & The April Fishes - Maintenant.opus.mp3" to c32964b176ff0a6890e6121c759bcd7430c92f4248014cb3eeb6cc37991b3d10
We havent been able to handle folders since the Great Reset - patience grasshopper
Similarly we can create and edit registers, we can’t yet actually read the populated registers.