Entomb mesh data and logs

This commit is contained in:
Bob Mottram 2016-07-28 19:58:28 +01:00
parent b47c62be6b
commit 9b00962d0b
1 changed files with 66 additions and 66 deletions

View File

@ -52,11 +52,18 @@ MESH_INSTALL_COMPLETED=/root/.mesh_setup_completed
MESH_INSTALL_SETUP=/root/.initial_mesh_setup
MESH_AMNESIC=/root/.amnesic
# Tomb containing logs
TOMB_LOG_SIZE_MB=32
# size of the tomb used to store qtox settings
TOMB_TOX_SIZE_MB=64
# Tomb containing logs
TOMB_LOG_SIZE_MB=32
# Tomb containing tox bootstrap
TOMB_TOX_BOOTSTRAP_SIZE_MB=32
# Tomb containing zeronet
TOMB_ZERONET_CONFIG_SIZE_MB=10
TOMB_ZERONET_DATA_SIZE_MB=128
function create_ram_disk {
ramdisk_size_mb=$1
@ -111,25 +118,7 @@ function configure_zeronet {
echo $"zeronet daemon updated to P${PEER_ID}.local" >> $INSTALL_LOG
}
function remove_zeronet_blog {
blog_address=$(cat $MESH_INSTALL_DIR/zeronet/blog.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_BLOG_ADDRESS=${blog_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/*.json
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/*.html
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/data/*
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/img/post/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/img/post
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS/img/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_BLOG_ADDRESS
fi
}
function configure_zeronet_blog {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_blog
fi
echo $'Updating ZeroNet Blog' >> $INSTALL_LOG
ZERONET_DEFAULT_BLOG_TITLE="${MY_USERNAME}'s Blog"
@ -207,24 +196,7 @@ function configure_zeronet_blog {
echo $'Update of ZeroNet Blog completed' >> $INSTALL_LOG
}
function remove_zeronet_mail {
mail_address=$(cat $MESH_INSTALL_DIR/zeronet/mail.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_MAIL_ADDRESS=${mail_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/*.json
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/*.html
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/users/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/users
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS
fi
}
function configure_zeronet_mail {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_mail
fi
echo $'Updating ZeroNet Mail' >> $INSTALL_LOG
ZERONET_DEFAULT_MAIL_TITLE="${MY_USERNAME}'s Mail"
@ -302,23 +274,7 @@ function configure_zeronet_mail {
echo $'Update of ZeroNet Mail completed' >> $INSTALL_LOG
}
function remove_zeronet_forum {
forum_address=$(cat $MESH_INSTALL_DIR/zeronet/forum.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_FORUM_ADDRESS=${forum_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/data/users/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/data/users
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/data/*
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/*.html
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS/*.json
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_FORUM_ADDRESS
fi
}
function configure_zeronet_forum {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_forum
fi
echo $'Updating ZeroNet Forum' >> $INSTALL_LOG
ZERONET_DEFAULT_FORUM_TITLE="${MY_USERNAME}'s Forum"
@ -391,19 +347,7 @@ function configure_zeronet_forum {
echo $'Update of ZeroNet Forum completed' >> $INSTALL_LOG
}
function remove_zeronet_id {
zeroid_address=$(cat $MESH_INSTALL_DIR/zeronet/zeroid.txt | grep "Site address" | awk -F ':' '{print $2}')
ZERONET_ID_ADDRESS=${zeroid_address//[[:blank:]]/}
if [ -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_ID_ADDRESS ]; then
shred -zu $MESH_INSTALL_DIR/zeronet/data/$ZERONET_ID_ADDRESS/*
rm -rf $MESH_INSTALL_DIR/zeronet/data/$ZERONET_ID_ADDRESS
fi
}
function configure_zeronet_id {
if [ -f $MESH_INSTALL_COMPLETED ]; then
remove_zeronet_id
fi
echo $'Updating ZeroID' >> $INSTALL_LOG
cd $MESH_INSTALL_DIR/zeronet
@ -479,6 +423,7 @@ function configure_toxcore {
echo $'Enabling toxcore daemon' >> $INSTALL_LOG
systemctl enable tox-bootstrapd.service
echo $'Regenerating Tox bootstrap node keys' >> $INSTALL_LOG
systemctl stop tox-bootstrapd.service
if [ -f /var/lib/tox-bootstrapd/keys ]; then
@ -606,7 +551,16 @@ function setup_amnesic_data {
tomb_name=log
create_tomb ${tomb_name} $TOMB_LOG_SIZE_MB
if [ -d /media/${tomb_name} ]; then
INSTALL_LOG=/media/${tomb_name}/${PROJECT_NAME}.log
if [ -d /var/log ]; then
if [ ! -d /var/log_base ]; then
mv /var/log /var/log_base
fi
fi
ln -s /media/${tomb_name} /var/log
cp -rp /var/log_base/* /media/${tomb_name}
echo "${tomb_name} tomb created" >> $INSTALL_LOG
else
echo "WARNING: ${tomb_name} tomb not found" >> $INSTALL_LOG
fi
tomb_name=tox
@ -626,6 +580,52 @@ function setup_amnesic_data {
echo "WARNING: ${tomb_name} tomb not found" >> $INSTALL_LOG
fi
tomb_name=zeronet-config
create_tomb ${tomb_name} $TOMB_ZERONET_CONFIG_SIZE_MB
if [ -d /media/${tomb_name} ]; then
if [ ! -d /home/${MY_USERNAME}/.config ]; then
mkdir -p /home/${MY_USERNAME}/.config
fi
if [ -d /home/${MY_USERNAME}/.config/${tomb_name} ]; then
rm -rf /home/${MY_USERNAME}/.config/${tomb_name}
fi
ln -s /media/${tomb_name} /home/${MY_USERNAME}/.config/${tomb_name}
chown -R ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/.config
chown -R ${MY_USERNAME}:${MY_USERNAME} /media/${tomb_name}
echo "${tomb_name} tomb created" >> $INSTALL_LOG
else
echo "WARNING: ${tomb_name} tomb not found" >> $INSTALL_LOG
fi
tomb_name=zeronet-data
create_tomb ${tomb_name} $TOMB_ZERONET_DATA_SIZE_MB
if [ -d /media/${tomb_name} ]; then
if [ -d /var/lib/zeronet ]; then
if [ ! -d /var/lib/zeronet_base ]; then
mv /var/lib/zeronet /var/lib/zeronet_base
fi
fi
ln -s /media/${tomb_name} /var/lib/zeronet
cp -rp /var/lib/zeronet_base/* /media/${tomb_name}
echo "${tomb_name} tomb created" >> $INSTALL_LOG
else
echo "WARNING: ${tomb_name} tomb not found" >> $INSTALL_LOG
fi
tomb_name=tox-bootstrapd
create_tomb ${tomb_name} $TOMB_TOX_BOOTSTRAP_SIZE_MB
if [ -d /media/${tomb_name} ]; then
if [ -d /var/lib/tox-bootstrapd ]; then
if [ ! -d /var/lib/tox-bootstrapd_base ]; then
mv /var/lib/tox-bootstrapd /var/lib/tox-bootstrapd_base
fi
fi
ln -s /media/${tomb_name} /var/lib/tox-bootstrapd
cp -rp /var/lib/tox-bootstrapd_base/* /media/${tomb_name}
echo "${tomb_name} tomb created" >> $INSTALL_LOG
else
echo "WARNING: ${tomb_name} tomb not found" >> $INSTALL_LOG
fi
}
# whether to reset the identity