-
-
Save rnauber/9f579d1480db4cc5a9a3c97c00c52fb9 to your computer and use it in GitHub Desktop.
# installs the browser-based editor Codiad | |
# | |
# call via: | |
# bash <(wget -qO- https://gist.githubusercontent.com/rnauber/9f579d1480db4cc5a9a3c97c00c52fb9/raw/install_codiad.sh ) | |
# | |
DEST="$HOME/codiad" | |
ADDR=127.0.0.1:9876 | |
echo -e "\033[1;32m Installing prerequisites... \033[0m" | |
pkg install -y php readline git | |
if [ -e "$DEST" ] | |
then | |
echo -en "\033[1;31m" | |
read -p " The folder $DEST already exists, please press 'y' to delete it! " -n 1 -r | |
echo -e "\033[0m" | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
rm -rf "$DEST" | |
else | |
echo -e "\033[1;31m Aborting ! \033[0m" | |
exit 1 | |
fi | |
fi | |
echo -e "\033[1;32m Cloning repository ... \033[0m" | |
git clone --depth 1 https://github.com/francescom/Codiad "$DEST" | |
cat > "$DEST/config.php" << XXXXX | |
<?php | |
/* | |
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed | |
* as-is and without warranty under the MIT License. See | |
* [root]/license.txt for more. This information must remain intact. | |
*/ | |
////////////////////////////////////////////////////////////////// | |
// CONFIG | |
////////////////////////////////////////////////////////////////// | |
// PATH TO CODIAD | |
define("BASE_PATH", "$DEST"); | |
// BASE URL TO CODIAD (without trailing slash) | |
define("BASE_URL", "$ADDR"); | |
// THEME : default, modern or clear (look at /themes) | |
define("THEME", "default"); | |
// ABSOLUTE PATH | |
define("WHITEPATHS", BASE_PATH . ",/"); | |
// SESSIONS (e.g. 7200) | |
\$cookie_lifetime = "0"; | |
// TIMEZONE | |
date_default_timezone_set("Asia/Damascus"); | |
// External Authentification | |
define("AUTH_PATH", "$DEST/noauth.php"); | |
////////////////////////////////////////////////////////////////// | |
// ** DO NOT EDIT CONFIG BELOW ** | |
////////////////////////////////////////////////////////////////// | |
// PATHS | |
define("COMPONENTS", BASE_PATH . "/components"); | |
define("PLUGINS", BASE_PATH . "/plugins"); | |
define("THEMES", BASE_PATH . "/themes"); | |
define("DATA", BASE_PATH . "/data"); | |
define("WORKSPACE", BASE_PATH . "/workspace"); | |
// URLS | |
define("WSURL", BASE_URL . "/workspace"); | |
// Marketplace | |
//define("MARKETURL", "http://market.codiad.com/json"); | |
// Update Check | |
//define("UPDATEURL", "http://update.codiad.com/?v={VER}&o={OS}&p={PHP}&w={WEB}&a={ACT}"); | |
//define("ARCHIVEURL", "https://github.com/Codiad/Codiad/archive/master.zip"); | |
//define("COMMITURL", "https://api.github.com/repos/Codiad/Codiad/commits"); | |
XXXXX | |
cat > "$DEST/data/users.php" << XXXXX | |
<?php | |
/*|[{"username":"termux","password":"6558b496fb21c09603c5b28c998481ae075228ad","project":"\/data\/data\/com.termux\/files\/home\/"}]|*/ | |
?> | |
XXXXX | |
cat > "$DEST/data/projects.php" << XXXXX | |
<?php | |
/*|[{"name":"termux_home","path":"\/data\/data\/com.termux\/files\/home\/"}]|*/ | |
?> | |
XXXXX | |
cat > "$DEST/noauth.php" << XXXXX | |
<?php | |
\$_SESSION['user'] = 'termux'; | |
?> | |
XXXXX | |
cat > "$PREFIX/bin/codiad" << XXXXX | |
cd "$DEST" | |
php -S $ADDR & | |
xdg-open http://$ADDR | |
wait | |
XXXXX | |
chmod +x "$PREFIX/bin/codiad" | |
echo -e "\033[1;32m Done! Try starting it with 'codiad'... \033[0m" | |
Thanks for the feedback, I fixed 2. but I am a little bit wary of 1. ..
Yes, I agree, there should be definitely a way to turn it on or off like a param or variable or another command. On the other hand codiad on the mobile screen is of little use on my phone while connecting a browser from any PC is fantastic. I also wonder if the PHP webserver has any form of authentication...
Yes, codiad supports authentication and I disabled it on line 84 ff. But in order to use it across a network, https should be used.
I would use a simpler approach: start a sshd server on the device and forward codiads port to your PC.
How can I start the it on Termux?
just type
codiad
I installed it using the link present in Termux wiki page but codiad
have me an error message that the command isn't found.
What is the output of the installer/ the error message? Does closing and reopening termux help?
I have gone past that. A new issue is the non-responsive nature of the editor after it is launched. It doesn't open the documents to be edited.
Oh, I think I know the problem! The wiki points to an old revision of this gist. Please try:
wget https://gist.githubusercontent.com/rnauber/9f579d1480db4cc5a9a3c97c00c52fb9/raw/install_codiad.sh -O- | bash
If it works, you are very welcome to update the wiki!
Thank you!
I used that new link but it still doesn't work. How can I totally erase the it and re-install it? Maybe its former data are conflicting.
Please try again!
The new way to call the script is
bash <(wget -qO- https://gist.githubusercontent.com/rnauber/9f579d1480db4cc5a9a3c97c00c52fb9/raw/install_codiad.sh )
I'd like to install it on a ubunto distro (andronix) installed within Termux. so I wonder what to use user and password at users.php file
hello
when opening files/folder/settings menu in browser using codiad , it kept on loading and then nothing happens.
I installed it earlier then it was working fine .
This time its not working for me
any suggestions ?
Nothing works not able to create, open or edit files using termux Android. Can someone tell me how to uninstall this? Thanks for your help
Uninstall script for bash
#!/bin/bash
DEST="$HOME/codiad"
ADDR=127.0.0.1:9876
echo -e "\033[1;32m Uninstalling Codiad... \033[0m"
if [ -e "$DEST" ]
then
read -p "Do you want to uninstall Codiad and delete the installation folder $DEST? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
pkill -f "php -S $ADDR"
rm -rf "$DEST"
rm -f "$PREFIX/bin/codiad"
echo -e "\033[1;32m Codiad has been uninstalled. \033[0m"
else
echo -e "\033[1;31m Uninstallation aborted! \033[0m"
exit 1
fi
else
echo -e "\033[1;31m Codiad is not installed, nothing to uninstall. \033[0m"
fi
Using ADDR=0.0.0.0:9876 allows you to open files in your mobile using any computer with a browser as a screen/keyboard.
You can remove the xdg-open http://$ADDR, in case
Codiad had a bug in https://github.com/Codiad/Codiad I patched in https://github.com/francescom/Codiad until they fix it.
PHP complained that two functions were already defined so I wrapped them into if(function_exists(..)) {..}, that is the only patch