.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 📱 Termux Projects 🚀
2 |
3 | Welcome to Awesome Termux Projects! This repository is a collection of cool projects that you can do with Termux, ranging from setting up web servers to running torrent servers and much more!
4 |
5 | ## What is Termux?
6 |
7 | [Termux](https://termux.dev/en/) is a powerful terminal emulator for Android that brings the power of Linux to your smartphone or tablet. With Termux, you can access a full Linux command-line environment on your Android device, enabling you to run various programs and scripts right from your pocket!
8 |
9 | ## 🎉 Get Started
10 |
11 | Ready to dive into the world of Termux projects? Follow these simple steps to get started:
12 |
13 | 1. **Install Termux**: If you want to install and setup a full Linux environment in your Android device take a look at my other repo (with a lot of guides in video): [Termux Desktops 😊](https://github.com/LinuxDroidMaster/Termux-Desktops)
14 |
15 | 2. **Choose your project!**: Take a look at all the projects in this repository or feel free to add anything you find useful!
16 |
17 | # 🔥 Projects 🔥
18 |
19 | - [🐋 Docker on Android](./projects/docker_android.md)
20 |
21 | - [🖥️ HomeLab server: Turn your Android device into a server](./projects/homelab_server.md)
22 |
23 | - [🌐 LAMP (Apache - MySQL - PHP) Web Server: Set your own WordPress page](./projects/lamp_server_wordpress.md)
24 |
25 | - [⬇️ Torrent Server with web interface using Transmission](./projects/torrent_server.md)
26 |
27 |
28 | ### Programming
29 |
30 | - [🌍 Next.js Web Development in Termux: Build & Deploy a Website](https://youtu.be/5jLo39VhsNU)
31 |
32 | - [🐍 How to program in PYTHON using Android](https://youtu.be/gD3ZS69z2os?si=dxGFOoHkvEG_a4jk)
33 |
34 | - [🤖 How to run a TELEGRAM BOT in Android](/projects/telegram_bot.md)
35 |
36 | - [🌐 How to program in JAVASCRIPT using Android](https://youtu.be/hpCsKbkm9QM?si=k_zpf_NdcXXTehY4)
37 |
38 |
39 | ## 🤝 Contributing
40 | We welcome contributions! Whether you have a new project idea or want to improve existing ones, feel free to submit a pull request. Don't forget to add some emojis to make your contribution even more awesome! 😎
41 |
42 | ## 💬 Support
43 | Need help? Have suggestions or feedback? Join our [Discord](discord.gg/ddvpK997Qu) or [Telegram](https://t.me/+yE-asc3LzXY0ZGY0) communities to connect with other Termux enthusiasts and get assistance from fellow developers.
44 |
45 | ## ❤️ Share the Love
46 | If you find this repository helpful, don't forget to give it a ⭐️ star to show your support! Also, spread the word and share it with your friends who might be interested in exploring Termux projects.
47 |
--------------------------------------------------------------------------------
/projects/docker_android.md:
--------------------------------------------------------------------------------
1 | # How to run Docker on Android
2 |
3 | All the process is described in the following repository: https://github.com/AntonyZ89/docker-qemu-arm and in my [YOUTUBE VIDEO](https://youtu.be/vSUZ1xEhHfo?feature=shared)
4 |
5 | ## 🛠️ Prerequisites and tips
6 |
7 | * **I recommend you to setup the following environment to use docker from Termux native graphical desktop: [How to install Termux X11 native DESKTOP on ANDROID - Linux on Android
8 | ](https://youtu.be/rq85dxMb7e4?feature=shared)**
9 |
10 | * **Remember the Alpine environment credentials:**
11 | ```
12 | user: root
13 | password: Secret123
14 | ```
15 |
16 | * **How to forward a port from Termux native to Alpine to be able to access the apps:**
17 |
18 | From the `docker-qemu-arm/alpine` folder:
19 | ```
20 | ssh -i qemukey -L 8080:localhost:4647 root@localhost -p 2222
21 | ```
22 |
23 | This will forward the port `8080` in Termux native to the port `4647` in the Alpine container.
24 |
25 |
26 |
27 | ## 🐋 How to run docker containers
28 |
29 | 1. Login into Alpine with the creds from before
30 | ```
31 | /docker-qemu-arm/alpine/startqemu.sh
32 | ```
33 |
34 | 2. Create a new folder:
35 | ```
36 | mkdir nginx
37 | cd nginx
38 | ```
39 |
40 | 3. Create an index file and paste the following content:
41 | ```
42 | nano index.html
43 | ```
44 | ```
45 |
46 |
47 |
48 |
49 |
50 | Prueba de Nginx
51 |
61 |
62 |
63 | Hello from Docker!
64 | Don't forget to subscribe to DroidMaster :)
65 |
66 |
67 | ```
68 |
69 | 4. Create a Dockerfile with the following content:
70 | ```
71 | nano Dockerfile
72 | ```
73 | ```
74 | FROM nginx:alpine
75 |
76 | RUN rm /etc/nginx/conf.d/default.conf
77 |
78 | COPY nginx.conf /etc/nginx/conf.d/
79 |
80 | COPY index.html /usr/share/nginx/html/index.html
81 |
82 | EXPOSE 80
83 |
84 | CMD ["nginx", "-g", "daemon off;"]
85 | ```
86 |
87 | 5. Create a Nginx config file:
88 | ```
89 | nano nginx.conf
90 | ```
91 | ```
92 | server {
93 | listen 80;
94 | server_name localhost;
95 |
96 | location / {
97 | root /usr/share/nginx/html;
98 | index index.html;
99 | }
100 | }
101 | ```
102 |
103 | 6. Lets build and run our docker:
104 | ```
105 | docker build -t my-nginx-container .
106 | docker run -d -p 4647:80 --name nginx-container my-nginx-container
107 | ```
108 |
109 | 7. Other useful commands:
110 |
111 | Check running containers:
112 | ```
113 | docker ps
114 | ```
115 | Check all the containers in the system:
116 | ```
117 | docker ps -a
118 | ```
119 | Start/Stop a container:
120 | ```
121 | docker stop my-nginx-container
122 | ```
--------------------------------------------------------------------------------
/projects/homelab_server.md:
--------------------------------------------------------------------------------
1 | # 🖥️ HomeLab server: Turn your Android device into a server
2 |
3 | All this process is documented in the following [video](https://www.youtube.com/watch?v=PxTnMAuheaw)
4 |
5 |
6 | # 📚 Index
7 |
8 | * 🏁 [First steps](#first-steps)
9 | * 🎨 [Terminal customization: Starship](#terminal-customization)
10 | * 💻 [Install OpenSSH (SSH server)](#openssh)
11 | * 📂 [Mount external USB HDD](#external_device)
12 | * 🤖 [Start Termux on boot](#termux-boot)
13 |
14 |
15 |
16 |
17 | ---
18 | ---
19 |
20 |
21 |
22 | ## 🏁 First steps
23 | - **Download and install Termux app from the [official GitHub repository](https://github.com/termux/termux-app).**
24 |
25 | - **Update and upgrade packages:**
26 | ```
27 | pkg update
28 | pkg upgrade -y
29 | ```
30 |
31 | Tip: You can select the mirror corresponding to the area closest to you with the command:
32 | ```
33 | termux-change-repo
34 | ```
35 |
36 | Tip 2: You can access your device internal storage with the command
37 | ```
38 | termux-setups-storage
39 | ```
40 | You will see a new folder called `storage` with the content of your Android device
41 |
42 | ---
43 |
44 |
45 |
46 | ## 🎨 Terminal Customization: Starship
47 |
48 | - **Go to the installation section of the [official Starship site](https://starship.rs/guide/#step-1-install-starship) or just install it with the following command:**
49 | ```
50 | pkg install starship
51 | ```
52 |
53 | - **Select the [preset](https://starship.rs/presets/) you like the most and install it, for example:**
54 | ```
55 | starship preset gruvbox-rainbow -o ~/.config/starship.toml
56 | ```
57 |
58 | - **Add the following line at the end of the .bashrc file**
59 | ```
60 | cd
61 | nano .bashrc
62 | ```
63 | ```
64 | # Add the following line
65 | eval "$(starship init bash)"
66 | ```
67 |
68 |
69 | ---
70 |
71 |
72 |
73 | ## 💻 Install OpenSSH (SSH server)
74 |
75 | - **Install OpenSSH in Termux**
76 | ```
77 | pkg install openssh
78 | ```
79 |
80 | - **Initialize OpenSSH daemon**
81 | ```
82 | sshd
83 | ```
84 |
85 | Tip: You can check OpenSSH configuration in the following path:
86 | ```
87 | cat $PREFIX/etc/ssh/sshd_config
88 | ```
89 |
90 | - **Setup a password to login later**
91 | ```
92 | passwd
93 | ```
94 |
95 | - **Check the listening port (by default `8022`) in the tablet with the following command**
96 | ```
97 | logcat -S 'sshd:*'
98 | ```
99 |
100 | Tip: Check your username with the command `whoami` and the IP address with `ifconfig` or `ip a`
101 |
102 | - **Note: I will use the program called [MobaXterm](https://mobaxterm.mobatek.net/download.html) to connect to the tablet from my Windows PC**
103 |
104 | 
105 | 
106 |
107 |
108 |
109 |
110 | ---
111 |
112 |
113 |
114 | ## 📂 Mount external USB HDD
115 |
116 | **Note: You need `ROOT` access for this part**
117 |
118 | - **Enter root terminal in Termux with `su` command**
119 | - You can find your device storage in the `/mnt` folder but for the external hard disk you need to find its path with the `blkid` command (in my case it is `/dev/block/sda1`).
120 |
121 | 
122 |
123 | - **Create a folder where we are going to mount the HDD:**
124 | ```
125 | cd /mnt
126 | mkdir HDD
127 | ```
128 |
129 | - **Mount the HDD with permissions to write on it (remember to change `/dev/block/sda1` with your path**
130 | ```
131 | mount -o uid=1000,gid=1000,umask=0000 /dev/block/sda1 HDD/
132 | ```
133 |
134 | Tip: You can mount the HDD inside a chroot environment like I show on the video so we can share it with other services like `Samba`, `Transmission`, etc.
135 |
136 | - [How to setup a samba server](https://pimylifeup.com/raspberry-pi-samba/)
137 |
138 | ---
139 |
140 |
141 |
142 | ## 🤖 Start Termux on boot
143 |
144 | - **Install Termux Boot app from the [official page](https://github.com/termux/termux-boot)**
145 |
146 | - **Follow the usage example from the [official wiki](https://wiki.termux.com/wiki/Termux:Boot):**
147 | ```
148 | mkdir ~/.termux/boot/
149 | nano ~/.termux/boot/start-sshd
150 | ```
151 | ```
152 | # Paste this
153 | #!/data/data/com.termux/files/usr/bin/sh
154 | termux-wake-lock
155 | sshd
156 | ```
157 |
158 | - **Add another file to start Termux services on boot**
159 | ```
160 | nano ~/.termux/boot/start-services
161 | ```
162 | ```
163 | # Paste this
164 | #!/data/data/com.termux/files/usr/bin/sh
165 | termux-wake-lock
166 | . $PREFIX/etc/profile
167 | ```
168 |
169 | Tip: Reboot your Android device and check that after a few secons Termux opens in background and you can connect to it with SSH (even with the device screen locked)
170 |
--------------------------------------------------------------------------------
/projects/images/homelab/blkid_output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/homelab/blkid_output.png
--------------------------------------------------------------------------------
/projects/images/homelab/ssh_connect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/homelab/ssh_connect.png
--------------------------------------------------------------------------------
/projects/images/homelab/ssh_connect_ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/homelab/ssh_connect_ok.png
--------------------------------------------------------------------------------
/projects/images/lamp_server/wordpress1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/lamp_server/wordpress1.png
--------------------------------------------------------------------------------
/projects/images/lamp_server/wordpress2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/lamp_server/wordpress2.png
--------------------------------------------------------------------------------
/projects/images/telegram_bot/bot_father_conversation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/telegram_bot/bot_father_conversation.png
--------------------------------------------------------------------------------
/projects/images/telegram_bot/telegram_bot_running.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/telegram_bot/telegram_bot_running.png
--------------------------------------------------------------------------------
/projects/images/torrent_server/torrent1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/torrent_server/torrent1.png
--------------------------------------------------------------------------------
/projects/images/torrent_server/torrent2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/42abd8b420835f1ccf05c1c5d4b69dae9ab1f7e8/projects/images/torrent_server/torrent2.png
--------------------------------------------------------------------------------
/projects/lamp_server_wordpress.md:
--------------------------------------------------------------------------------
1 | # LAMP Server on Android with Termux (Apache - MySQL - PHP)
2 |
3 | Here are the commands you need to configure a LAMP server in Termux. This will allow you to host your own web pages such as a Wordpress page on your Android device.
4 |
5 | All this process is documented in the following video: [How to install a LAMP web server on Termux](https://www.youtube.com/watch?v=3NKR_SGlTtY)
6 |
7 | 
8 | 
9 |
10 | ## 1. Setup Apache
11 | 1. Install Apache:
12 | ```
13 | sudo apt-get install apache2 -y
14 | ```
15 | 2. Modify the default port (the port 80 is restricted)
16 | ```
17 | nano /etc/apache2/ports.conf
18 | ```
19 | And change the line: 'Listen 80' to the port you want (for example, port 8082)
20 |
21 | 3. Start the Apache service
22 | ```
23 | sudo service apache2 start
24 | ```
25 | In case you want to check the status of the service (it should say 'apache2 is running'):
26 | ```
27 | sudo service apache2 status
28 | ```
29 | 4. Go to http://localhost:8082 and check that the Apache2 service works
30 |
31 |
32 | ## 2. Install PHP
33 | 1. Install PHP:
34 | ```
35 | sudo apt-get install php -y
36 | ```
37 | 2. To test that PHP is working go to `/var/www/html` and create a new index.php witht the following command (remove the index file first with `rm index.html`)
38 | ```
39 |
40 | ```
41 |
42 | ## 3. Install MariaDB (MySQL)
43 | 1. Install MariaDB:
44 | ```
45 | sudo apt-get install mariadb-server php-mysql -y
46 | ```
47 | 2. Run the MariaDB service:
48 | ```
49 | mysqld_safe
50 | ```
51 |
52 | 3. Open a new tab in the terminal and run the secure installation:
53 | ```
54 | sudo mysql_secure_installation
55 | ```
56 | For the recommended configuration I suggest taking a look at the video in the top of this file
57 |
58 | 4. Let's access the MySQL server and create the database needed for Wordpress:
59 | ```
60 | sudo mysql -uroot -p
61 | ```
62 | ```
63 | create database wordpress;
64 | ```
65 | ```
66 | GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'YOURPASSWORD';
67 | ```
68 | ```
69 | FLUSH PRIVILEGES;
70 | ```
71 |
72 |
73 | ## 4. Install WordPress
74 | 1. Download Wordpress latest version (firs move to the default apache path `cd /var/www/html/`):
75 | ```
76 | sudo wget https://wordpress.org/latest.tar.gz
77 | ```
78 | In case you need to install wget: `sudo apt install wget -y`
79 |
80 | 2. Extract WordPress:
81 | ```
82 | sudo tar xzf latest.tar.gz
83 | ```
84 |
85 | 3. Move the extracted content to the current direcoty
86 | ```
87 | sudo mv wordpress/* .
88 | ```
89 |
90 | 4. Remove unnecesary files
91 | ```
92 | sudo rm -rf wordpress latest.tar.gz
93 | ```
94 |
95 | 5. Set permissions to the files
96 | ```
97 | sudo chown -R www-data: .
98 | ```
99 |
100 | ## Acknowledgements
101 | I have obtained most of the information here from the following link: [How to install a LAMP server on a raspberry pi](https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress/2)
--------------------------------------------------------------------------------
/projects/scripts/telegram_bot/telegram_bot.py:
--------------------------------------------------------------------------------
1 | import os
2 | from telegram.ext import Application, CommandHandler
3 | import yt_dlp
4 |
5 | # Define the /start command handler
6 | async def start(update, context):
7 | await update.message.reply_text("Welcome! 🎉")
8 |
9 | # Define the /youtube command handler to handle the video download process
10 | async def download_youtube_video(update, context):
11 | # Send initial processing message
12 | await update.message.reply_text("📥 Message received, processing...")
13 |
14 | # Extract the URL from the command (e.g. /youtube URL)
15 | if len(context.args) > 0:
16 | url = context.args[0]
17 |
18 | # Define options for yt-dlp to download the best available quality
19 | ydl_opts = {
20 | 'format': 'best',
21 | 'outtmpl': '%(title)s.%(ext)s',
22 | 'noplaylist': True, # Ensure that only a single video is processed
23 | }
24 |
25 | try:
26 | # Download the video using yt-dlp
27 | with yt_dlp.YoutubeDL(ydl_opts) as ydl:
28 | info_dict = ydl.extract_info(url, download=True)
29 | video_title = info_dict.get('title', 'video')
30 | file_path = ydl.prepare_filename(info_dict) # Get the downloaded file path
31 |
32 | # Notify the user that the download was successful
33 | await update.message.reply_text(f"✅ Video '{video_title}' has been downloaded successfully!")
34 |
35 | # Send the downloaded video file back to the user
36 | with open(file_path, 'rb') as video_file:
37 | await update.message.reply_document(video_file)
38 |
39 | # Optionally, delete the file after sending it
40 | os.remove(file_path)
41 |
42 | except Exception as e:
43 | # Notify the user in case of an error
44 | await update.message.reply_text(f"⚠️ An error occurred: {str(e)}")
45 | else:
46 | # If no URL is provided, inform the user
47 | await update.message.reply_text("🔗 Please provide a valid YouTube URL. Usage: /youtube ")
48 |
49 | def main():
50 | TOKEN = "TOKEN_VALUE_FROM_BOTFATHER" # Replace with your actual token
51 |
52 | # Create the Application and pass it your bot's token
53 | application = Application.builder().token(TOKEN).build()
54 |
55 | # Add command handlers
56 | application.add_handler(CommandHandler('start', start))
57 | application.add_handler(CommandHandler('youtube', download_youtube_video))
58 |
59 | # Run the bot using polling (this blocks until the bot is stopped)
60 | application.run_polling()
61 |
62 | if __name__ == '__main__':
63 | main()
64 |
--------------------------------------------------------------------------------
/projects/telegram_bot.md:
--------------------------------------------------------------------------------
1 | # 🤖 How to run a TELEGRAM BOT in Android
2 |
3 | All this process is documented in the following [video - pending]()
4 |
5 | 
6 |
7 | # 📚 Index
8 |
9 | * 🏁 [First steps](#first-steps)
10 | * ⚙️ [Get Bot TOKEN](#step1)
11 | * 🤖 [Run the Telegram Bot](#step2)
12 |
13 |
14 |
15 |
16 | ---
17 | ---
18 |
19 |
20 |
21 | ## 🏁 First steps
22 |
23 | - **Download and install Termux app from the [official GitHub repository](https://github.com/termux/termux-app).**
24 |
25 | - **Update and upgrade packages:**
26 | ```
27 | pkg update
28 | pkg upgrade -y
29 | ```
30 |
31 | Tip: You can select the mirror corresponding to the area closest to you with the command:
32 | ```
33 | termux-change-repo
34 | ```
35 |
36 | - **Install Python (the language we are going to use for the bot)**
37 | ```
38 | pkg install python python-pip git
39 | ```
40 |
41 | ---
42 |
43 |
44 |
45 | ## ⚙️ Get Bot TOKEN
46 |
47 | - Open your Telegram and start a conversation to the bot used in Telegram to manage your bots: https://t.me/BotFather or `@BotFather`
48 |
49 | - Send the following message and follow the steps from the chat
50 | ```
51 | /newbot
52 | ```
53 | - Set a name for the bot: `AndroidTestingBot`
54 | - Set a @ or username for the bot (needs to end in `bot`): `DroidMaster_testing_bot`
55 |
56 | You will get your bot TOKEN (save it for later)
57 |
58 | 
59 |
60 | ---
61 |
62 |
63 |
64 | ## 🤖 Run the Telegram Bot
65 |
66 |
67 | - **Download the Telegram Bot template**
68 | ```
69 | wget https://raw.githubusercontent.com/LinuxDroidMaster/Termux-Projects/main/projects/scripts/telegram_bot/telegram_bot.py
70 | ```
71 |
72 | - **Replace the TOKEN in the `main` method with the one obtained in the previous step**
73 |
74 | ```
75 | # Replace this part (line 40): TOKEN_VALUE_FROM_BOTFATHER
76 | ```
77 |
78 | - **Install dependencies**
79 | ```
80 | pip install python-telegram-bot yt-dlp
81 | ```
82 |
83 | - **Run the BOT**
84 | ```
85 | python telegram_bot.py
86 | ```
87 |
88 | - **Run the BOT in background**
89 | ```
90 | python telegram_bot.py &
91 | ```
92 |
93 | - **Check and kill background process**
94 | ```
95 | ps aux | grep python # Get the PID
96 | pkill PID or kill 9 PID
97 | ```
98 |
--------------------------------------------------------------------------------
/projects/torrent_server.md:
--------------------------------------------------------------------------------
1 | # Torrent Server on Android with Termux (Transmission)
2 |
3 | Here are the commands you need to configure a Torrent server in Termux. This will allow you to host your own Torrent server with a web interface so you can upload your torrents files or magnet links from anywhere in your network.
4 |
5 | All this process is documented in the following [video](https://youtu.be/Q3eiAhAa00M?feature=shared)
6 |
7 | 
8 | 
9 |
10 | ## 1. Installing Transmission
11 |
12 | Once loged in Debian using Termux with proot-distro (you can see all the process explained [here](https://www.youtube.com/watch?v=mXkXzFqSeYE)) just install Transmission
13 | ```
14 | sudo apt install transmission -y
15 | ```
16 |
17 | ## 2. Edit Transmission default configuration
18 | You need to start the Transmission server at least once:
19 | ```
20 | sudo service transmission start
21 | ```
22 | Then, stop it
23 | ```
24 | sudo service transmission stop
25 | ```
26 | And then modify the default configuration
27 | ```
28 | sudo nano /etc/transmission-daemon/settings.json
29 | ```
30 | Modify the following parameters to setup the login into the web interface:
31 | ```
32 | "rpc-password": "Your_Password",
33 | "rpc-username": "Your_Username",
34 | "rpc-whitelist-enabled": "false",
35 | ```
36 |
37 | Now you are ready to log into the web interface: `http://your_device_ip:9091`
--------------------------------------------------------------------------------