jlj-installer.sh

Written on July 15, 2016

Bash file that installs terminal journal client jlj.pl onto the user’s computer.

Installer for legacy jlj 2.15 runs a config guide to setup user for jlj-legacy client. Development towards a newer client is currently undergoing. Client is downloaded from a private server. Please do not spam the service. Run this installer once per computer.

repos/docs

#!/bin/sh
# install-jlj.sh
# written by Sam Klein
# srukle.github.io

clear

USER="$(whoami)"
ORANGE='\033[0;33m'
RED='\033[0;31m'
PURPLE='\033[1;35m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m'

# Download client.
echo -e "${RED}Downloading jlj2.15.tar.gz.${NC}"
wget https://www.endersgame.net/~cheyan/code/jlj2.15.tar.gz
echo -e "${GREEN}Complete${NC}"

# Extract tar folder.
clear
echo -e "${ORANGE}Extracting.${NC}"
tar zxvf jlj2.15.tar.gz
echo -e "${GREEN}Complete${NC}"

#README.md
clear
echo "Would you like to look at the README file?"
echo -e "${CYAN}It's wise to read the docs before answering the prompts.${NC}"
echo -e "${CYAN}Type CRTL + X to exit nano.${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	nano jlj_215/README.JLJ
else
	echo "Alright... We'll skip this step."
fi

# Let's remove the config file. Now let's create a new one!
rm jlj_215/.livejournal.rc

clear
echo -e "What's your server? (example: www.dreamwidth.org) "
read SERVER
touch /home/$USER/.livejournal.rc
FILE=/home/$USER/.livejournal.rc
echo "          server: $SERVER" > $FILE

echo "         postcgi: /interface/flat" >> $FILE

clear
echo -e "What's your username? "
read NAME
echo "            user: $NAME" >> $FILE

clear
echo -e "What's your password? "
echo -e "${RED}WARNING:${NC} ${ORANGE}Your password is in clear text.${NC}"
read PASSWORD
echo "        password: $PASSWORD" >> $FILE # this should be encrypted in the future

echo "       community: " >> $FILE # this shouldn't be an issue as there's a prompt for this already, asking the user about this would be confusing

echo "" >> $FILE # empty space to maintain format

echo "        base dir: %s/.jlj" >> $FILE

# backup elif
clear
echo "Would you like a backup? [yes no]"
echo -e "	${CYAN}Keep a backup copy of your posts in ~/.jlj/sent ${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "          backup: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "          backup: no" >> $FILE
else
	echo -e "You ${RED}must${NC} answer yes or no."
	echo "Would you like a backup? [yes no]?"
	read -p "" RESP
	if [ $RESP = "yes" ]; then
		echo "          backup: yes" >> $FILE
	elif [ $RESP = "no" ]
	then
		echo "          backup: no" >> $FILE
	else
		echo -e "${RED}You failed to listen. I'm not making a function for this.${NC}"
		echo "Good bye. Try again."
		rm $FILE
		rm jlj2.15.tar.gz
		rm -r -f jlj_215
		exit
	fi
fi

echo "" >> $FILE # empty space to maintain format
echo "# incremented with 2.9" >> $FILE
echo "   editor offset: +19" >> $FILE
echo "" >> $FILE

#security
clear
echo "Security: [everyone private friends prompt]"
echo -e "	${CYAN}This will set who can see the post:"
echo -e "	everyone  unrestricted"
echo -e "	private   only the user who posted it can see it"
echo -e "	friends   either all friends or selected friend groups can see it"
echo -e "	prompt will ask you every time you run JLJ ${NC}"
read -p "" RESP
if [ $RESP = "everyone" ]; then
	echo "        security: everyone" >> $FILE
elif [ $RESP = "private" ]
then
	echo "        security: private" >> $FILE
elif [ $RESP = "friends" ]
then
	echo "        security: friends" >> $FILE
else
	echo -e "${RED}Failed.${NC} Security set to prompt."
	echo "        security: prompt" >> $FILE
fi

echo "	 friend0: friend group if 'friends' is selected, or omit for all friends" >> $FILE
echo "	 friend1: friend group if 'friends' is selected, or omit for all friends" >> $FILE
echo "          format: jerry" >> $FILE # this MUST change to external, as jerry has bugs, or we can fix jerry, perhaps testing external would be good

#mood elif
clear
echo "Prompt for mood? [yes no] "
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "     mood prompt: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "     mood prompt: no" >> $FILE
else
	echo -e "You ${RED}must${NC} answer yes or no."
	echo "Would you like a mood prompt? [yes no]"
	read -p "" RESP
	if [ $RESP = "yes" ]; then
		echo "     mood prompt: yes" >> $FILE
	elif [ $RESP = "no" ]
	then
		echo "     mood prompt: no" >> $FILE
	else
		echo -e "${RED}You failed to listen. I'm not making a function for this.${NC}"
		echo "Setting the default to yes. Deal with it. 8^|"
		echo "     mood prompt: yes" >> $FILE
	fi
fi

#music elif
clear
echo "Prompt for music? [yes no] "
echo -e "	${CYAN}Ask what music you're listening to.${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "    music prompt: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "    music prompt: no" >> $FILE
else
	echo -e "You ${RED}must${NC} answer yes or no."
	echo "Would you like a music prompt? [yes no]"
	read -p "" RESP
	if [ $RESP = "yes" ]; then
		echo "    music prompt: yes" >> $FILE
	elif [ $RESP = "no" ]
	then
		echo "    music prompt: no" >> $FILE
	else
		echo -e "${RED}You failed to listen. I'm not making a function for this.${NC}"
		echo "Setting the default to yes. Deal with it. 8^|"
		echo "    music prompt: yes" >> $FILE
	fi
fi

#picture elif
clear
echo "Prompt for picture? [yes no] "
echo -e "	${CYAN}Display a list of your pictures, and ask for which you want."
echo -e "	For best results, put in descriptive keywords for your pictures"
echo -e "	so that you know which is which when you are given this list.${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "  picture prompt: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "  picture prompt: no" >> $FILE
else
	echo -e "You ${RED}must${NC} answer yes or no."
	echo "Would you like a picture prompt? [yes no]"
	read -p "" RESP
	if [ $RESP = "yes" ]; then
		echo "  picture prompt: yes" >> $FILE
	elif [ $RESP = "no" ]
	then
		echo "  picture prompt: no" >> $FILE
	else
		echo -e "${RED}You failed to listen. I'm not making a function for this.${NC}"
		echo "Setting the default to yes. Deal with it. 8^|"
		echo "  picture prompt: yes" >> $FILE
	fi
fi
  
#community elif
clear
echo "Prompt for community? [yes no] "
echo -e "	${CYAN}Display a list of communities and journals you can post to,"
echo -e "	and ask for which to post to.${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "community prompt: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "community prompt: no" >> $FILE
else
	echo -e "You ${RED}must${NC} answer yes or no."
	echo "Would you like a community prompt? [yes no]"
	read -p "" RESP
	if [ $RESP = "yes" ]; then
		echo "community prompt: yes" >> $FILE
	elif [ $RESP = "no" ]
	then
		echo "community prompt: no" >> $FILE
	else
		echo -e "${RED}You failed to listen. I'm not making a function for this.${NC}"
		echo "Setting the default to yes. Deal with it. 8^|"
		echo "community prompt: yes" >> $FILE
	fi
fi

#Backdate
clear
echo "Use backdate: [yes no prompt]"
echo -e "	${CYAN}This will always prompt you for the date and time on startup"
echo -e "	of the client, if you have this set to yes.  It will not"
echo -e "	ask you if you have switched on quick mode (-q). ${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "  backdate entry: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "  backdate entry: no" >> $FILE
elif [ $RESP = "prompt" ]
then
	echo "  backdate entry: prompt" >> $FILE
else
	echo -e "${RED}Failed.${NC} Backdate set to no."
	echo "  backdate entry: no" >> $FILE
fi

#allow comments
clear
echo "Allow comments: [yes no prompt]"
echo -e "	${CYAN}Sets the allow comments field for the posts.  If set to yes,"
echo -e "	it will always allow comments.  If set to no, it will always"
echo -e "	disallow comments.  Prompt will ask you every time."
echo -e "	The default for this for quick mode is yes. ${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "  allow comments: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "  allow comments: no" >> $FILE
elif [ $RESP = "prompt" ]
then
	echo "  allow comments: prompt" >> $FILE
else
	echo -e "${RED}Failed.${NC} Allow comments set to yes."
	echo "  allow comments: yes" >> $FILE
fi

#email replies
clear
echo "Allow email replies: [yes no prompt]"
echo -e "	${CYAN}Sets the post such that replies to your event will be sent to you,"
echo -e "	via email, as defined on the server.  If set to yes, the server"
echo -e "	will email you replies to your post.  If set to no, the server"
echo -e "	will not email the replies to you.  Prompt will ask you every"
echo -e "	time.  The default for this for quick mode is yes. ${NC}"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "   email replies: yes" >> $FILE
elif [ $RESP = "no" ]
then
	echo "   email replies: no" >> $FILE
elif [ $RESP = "prompt" ]
then
	echo "   email replies: prompt" >> $FILE
else
	echo -e "${RED}Failed.${NC} Email replies set to yes."
	echo "   email replies: yes" >> $FILE
fi

echo "" >> $FILE

#proxy
clear
echo "Use proxy: [yes no]"
read -p "" RESP
if [ $RESP = "yes" ]; then
	echo "	   proxy: yes" >> $FILE
	echo "Proxy host: (example yourproxy.domain.tld) "
	read PROXYHOST
	echo "      proxy host: $PROXYHOST" >> $FILE
	echo "Proxy port: (probably 80)"
	read PROXYPORT
	echo "      proxy port: $PROXYPORT" >> $FILE
	
elif [ $RESP = "no" ]
then
	echo "	   proxy: no" >> $FILE
else
	echo -e "You ${RED}must${NC} answer yes or no."
	echo "Would you like to use a proxy? [yes no]"
	read -p "" RESP
	if [ $RESP = "yes" ]; then
		echo "	   proxy: yes" >> $FILE
		echo "Proxy host: (example yourproxy.domain.tld) "
		read PROXYHOST
		echo "      proxy host: $PROXYHOST" >> $FILE
		echo "Proxy port: (probably 80)"
		read PROXYPORT
		echo "      proxy port: $PROXYPORT" >> $FILE
	elif [ $RESP = "no" ]
	then
		echo "	   proxy: no" >> $FILE
	else
		echo -e "${RED}You failed to listen. I'm not making a function for this.${NC}"
		echo "Setting the default to no. Deal with it. 8^|"
		echo "	   proxy: no" >> $FILE
	fi
fi

#automate config files
echo "" >> $FILE
echo "# === new for 2.4 ===" >> $FILE
echo "" >> $FILE
echo "        autolink: yes" >> $FILE
echo "   ignore suffix: ~" >> $FILE
echo "  server retries: 5" >> $FILE
echo "     fast server: yes" >> $FILE
echo "" >> $FILE
echo "# === new for 2.7 ===" >> $FILE
echo "	formatter: Markdown	# executable program for formatting" >> $FILE
echo "" >> $FILE
echo "# === new for 2.8 ===" >> $FILE
echo " audio converter: lame --preset 24 _IN_ _OUT_" >> $FILE
echo "    audio upload: scp _IN_ user@host:public_html/Audio/voice/" >> $FILE
echo "       audio url: http://www.cis.rit.edu/~sdlpci/Audio/voice/" >> $FILE
echo "      audio icon: http://www.cis.rit.edu/~sdlpci/a.gif" >> $FILE
echo "" >> $FILE
echo "# === new for 2.15 ===" >> $FILE
echo "character encoding: utf-8 # see the bottom of the readme!!" >> $FILE
chmod 600 .livejournal.rc

#install to system or folder
clear
echo "Now installing to your system."
clear
echo "Binaries will be found in your Home folder."
mv jlj_215 /home/$USER/.jlj
rm -r -f /home/$USER/.jlj/jlj_215
echo "alias jlj='perl /home/$USER/.jlj/jlj.pl'" >> ~/.profile
source ~/.profile

Take me home.

Check out the archive.