Compare commits
	
		
			24 Commits
		
	
	
		
			63e402aaac
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						2a0bf7b12e
	
				 | 
					
					
						|||
| 
						
						
							
						
						e81096c0a1
	
				 | 
					
					
						|||
| 
						
						
							
						
						9ba8deb6d4
	
				 | 
					
					
						|||
| 
						
						
							
						
						b0c9da68c3
	
				 | 
					
					
						|||
| 
						
						
							
						
						ca0a4a6e78
	
				 | 
					
					
						|||
| 
						
						
							
						
						21364ee8ad
	
				 | 
					
					
						|||
| 
						
						
							
						
						99d125ddc4
	
				 | 
					
					
						|||
| 
						
						
							
						
						1d646a2945
	
				 | 
					
					
						|||
| 
						
						
							
						
						b5ea01a380
	
				 | 
					
					
						|||
| 
						
						
							
						
						729f2ea8ea
	
				 | 
					
					
						|||
| 
						
						
							
						
						3d660fa797
	
				 | 
					
					
						|||
| 
						
						
							
						
						336fccdaaa
	
				 | 
					
					
						|||
| 
						
						
							
						
						adf91b6ca7
	
				 | 
					
					
						|||
| 
						
						
							
						
						801ea06083
	
				 | 
					
					
						|||
| 
						
						
							
						
						157ea8d696
	
				 | 
					
					
						|||
| 
						
						
							
						
						e8a683c79d
	
				 | 
					
					
						|||
| 
						
						
							
						
						0b509705ca
	
				 | 
					
					
						|||
| 
						
						
							
						
						0a9b7e65f7
	
				 | 
					
					
						|||
| 
						
						
							
						
						1fd15e5880
	
				 | 
					
					
						|||
| 
						
						
							
						
						abc1614427
	
				 | 
					
					
						|||
| 
						
						
							
						
						13a9d0af4a
	
				 | 
					
					
						|||
| 
						
						
							
						
						535a4f8d54
	
				 | 
					
					
						|||
| 
						
						
							
						
						874f32a33f
	
				 | 
					
					
						|||
| 
						
						
							
						
						b08d72152b
	
				 | 
					
					
						
@@ -1,9 +1,9 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONFIG=/etc/nginx/sites-enabled/$1
 | 
			
		||||
CONFIG=/etc/nginx/sites-available/$1
 | 
			
		||||
DOMAIN=$2
 | 
			
		||||
 | 
			
		||||
IP=$(ping -c 1 $DOMAIN | awk '{print $3}' | head -n 1 | sed 's\(\\' | sed 's\)\\')
 | 
			
		||||
IP=$(dig $DOMAIN +short)
 | 
			
		||||
IP_OLD=$(grep -A0 '#DYNAMIC' $CONFIG | awk '{print $2}' | cut -f1 -d ';')
 | 
			
		||||
 | 
			
		||||
if [ "$IP" != "$IP_OLD" ]
 | 
			
		||||
@@ -14,9 +14,9 @@ then
 | 
			
		||||
		sed -i "s/$IP_OLD/$IP/" $CONFIG
 | 
			
		||||
		systemctl restart nginx
 | 
			
		||||
	else
 | 
			
		||||
		echo bruh
 | 
			
		||||
		echo nginx test failed
 | 
			
		||||
	fi
 | 
			
		||||
else
 | 
			
		||||
	echo bruh
 | 
			
		||||
	echo IP IS SAME
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								nginx-allow-dynamicip/readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								nginx-allow-dynamicip/readme.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
# NGINX ALLOW DYNAMIC IP
 | 
			
		||||
## Configure nginx config files to edit IP based on domain name
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Requirements
 | 
			
		||||
`dig` \
 | 
			
		||||
dig is most likely installed on your distro but incase it isn't install it first
 | 
			
		||||
 | 
			
		||||
### Usage
 | 
			
		||||
First, get the script and make it executable:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
curl -O https://git.shihaam.dev/shihaam/sarmic/raw/branch/master/nginx-allow-dynamicip/nginx-allow-dynamicip.sh
 | 
			
		||||
chmod +x nginx-allow-dynamicip.sh
 | 
			
		||||
```
 | 
			
		||||
Make sure your nginx config server block contain "#DYNAMIC" after the IP you want to change dynamically\
 | 
			
		||||
Something like the following:
 | 
			
		||||
```nginx
 | 
			
		||||
        #Block public access
 | 
			
		||||
        allow 1.1.1.1; #DYNAMIC
 | 
			
		||||
        deny   all;
 | 
			
		||||
```
 | 
			
		||||
Excute the script as root (or with sudo) with 1st argument for config file and 2nd argument with domain of the IP you want to allow \
 | 
			
		||||
`sudo ./nginx-allow-dynamicip.sh db-sarlinode.shihaam.dev home.shihaam.me`
 | 
			
		||||
 | 
			
		||||
### Automate with cron
 | 
			
		||||
Run `crontab -e` as root as this script needs to edit nginx config file and restart nginx
 | 
			
		||||
```bash
 | 
			
		||||
sudo crontab -e
 | 
			
		||||
```
 | 
			
		||||
I have it configured to update once every hour like this
 | 
			
		||||
```bash
 | 
			
		||||
0 * * * * /home/shihaam/scripts/nginx-allow-dynamicip.sh freezer.shihaam.me home.shihaam.me
 | 
			
		||||
```
 | 
			
		||||
### Notes
 | 
			
		||||
It is important that your nginx config files are in `/etc/nginx/sites-available/` and symlinked to `/etc/nginx/sites-enabled/`,\
 | 
			
		||||
This is done by default on Debian and Ubuntu, I noticed this is not how it's configured by default on Arch Linux and CentOS, If you're using those you have bigger issues. Tested and verifed to work on Debian Linux.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								x11vnc-remote-extended-display/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								x11vnc-remote-extended-display/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
# Use another device as an auxiliary display for a xorg GNU/Linux
 | 
			
		||||
With x11vnc, you can use your another device as a display that extends or mirrors your xorg GNU/Linux desktop.
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
## Get ready.
 | 
			
		||||
- Before continuing, Make sure that your GNU/Linux system is running X Display server and connected to the same network.
 | 
			
		||||
- You can use x11vnc wirelessly, but to keep connection stable, Connect your another device to wired network other either by Ethernet or USB Tethering.
 | 
			
		||||
 | 
			
		||||
If you dont want to use other deivce keyboard, mouse or trackpad to control your GNU/Linux system you can enable view only mode in VNC settings.
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
							
								
								
									
										46
									
								
								x11vnc-remote-extended-display/extended-display.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								x11vnc-remote-extended-display/extended-display.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
dependency_check(){
 | 
			
		||||
  for DEPENDENCY; do
 | 
			
		||||
    if ! command -v "$DEPENDENCY" 1>/dev/null; then
 | 
			
		||||
     printf "%s not found. Please install it.\n" "$DEPENDENCY" >&2
 | 
			
		||||
      exit 2
 | 
			
		||||
    fi
 | 
			
		||||
    done
 | 
			
		||||
  unset DEPENDENCY
 | 
			
		||||
}
 | 
			
		||||
dependency_check arandr x11vnc xrandr gtf
 | 
			
		||||
 | 
			
		||||
read -p 'Enter client width: ' CLIENT_WIDTH
 | 
			
		||||
read -p 'Enter client heigh: ' CLEINT_HEIGHT
 | 
			
		||||
read -p 'Enter client refresh rate: ' REFRESH_RATE
 | 
			
		||||
 | 
			
		||||
MODELINE=$(gtf $CLIENT_WIDTH $CLEINT_HEIGHT $REFRESH_RATE | grep Modeline | sed 's/Modeline//') #resolution of client machine (width, height, refreshrate)
 | 
			
		||||
RESOLUTION=$(echo $MODELINE | awk '{print $1}')
 | 
			
		||||
echo "---------------"
 | 
			
		||||
echo $MODELINE
 | 
			
		||||
echo "---------------"
 | 
			
		||||
read -p 'enter the above Modeline: ' MODELINE
 | 
			
		||||
xrandr --newmode $MODELINE
 | 
			
		||||
 | 
			
		||||
echo Checking avaible ports..
 | 
			
		||||
echo "---------------"
 | 
			
		||||
xrandr | grep disconnected | awk '{print $1}'
 | 
			
		||||
echo "---------------"
 | 
			
		||||
read -p 'Enter one of the ports to be used for VNC: ' PORT
 | 
			
		||||
 | 
			
		||||
echo Adding new display
 | 
			
		||||
xrandr --addmode $PORT $RESOLUTION
 | 
			
		||||
sleep 2
 | 
			
		||||
echo Activating new display
 | 
			
		||||
sleep 2
 | 
			
		||||
xrandr --output $PORT --mode $RESOLUTION
 | 
			
		||||
echo  "---------------"
 | 
			
		||||
echo Configure the new diplay where you want
 | 
			
		||||
echo  "---------------"
 | 
			
		||||
sleep 3
 | 
			
		||||
arandr >> /dev/null
 | 
			
		||||
GEO=$(xrandr | grep $PORT | awk '{print $3}')
 | 
			
		||||
echo Starting VNC Server
 | 
			
		||||
sleep 3
 | 
			
		||||
x11vnc -clip $GEO
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								x11vnc-remote-extended-display/img/arandr-ss.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								x11vnc-remote-extended-display/img/arandr-ss.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 20 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								x11vnc-remote-extended-display/img/extended-pic.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								x11vnc-remote-extended-display/img/extended-pic.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 176 KiB  | 
		Reference in New Issue
	
	Block a user