I have apache installed. If you don’t: sudo apt-get install apache2.

cd /usr/lib/cgi-bin

# Make a file and let everyone execute it
sudo touch test.sh && chmod a+x test.sh
Then put the some code in the file. For example:

#!/bin/bash
# get today’s date
OUTPUT=»$(date)»
# You must add following two lines before
# outputting data to the web browser from shell
# script
echo «Content-type: text/html»
echo «»
echo «<html><head><title>Demo</title></head><body>»
echo «Today is $OUTPUT <br>»
echo «Current directory is $(pwd) <br>»
echo «Shell Script name is $0»
echo «</body></html>»

We also have to enable mod_cgi a2enmod cgi if not already enabled

 

cat /etc/rc.local

echo «4» > /sys/class/gpio/export
echo «out» > /sys/class/gpio/gpio4/direction
echo «1» > /sys/class/gpio/gpio4/value

exit 0

 

cat /usr/lib/cgi-bin/on.sh
#!/bin/bash
# get today’s date
OUTPUT=»$(date)»
# You must add following two lines before
# outputting data to the web browser from shell
# script
echo «0» > /sys/class/gpio/gpio4/value
echo «Content-type: text/html»
echo «»
 

Reverse SSH Tunneling

Posted: 25th Май 2016 by shmyak in Пингвин

#apt-get install autossh

#ssh-keygen…

# cat /etc/rc.local

/usr/bin/autossh -M {monitoring port} -N -f -o «PubkeyAuthentication=yes» -o «PasswordAuthentication=no» -o «ServerAliveInterval 30» -o «ServerAliveCountMax 3» -i /path/to/ssh_key -R 12345:localhost:{ssh port} {user}@{remote server} -p {remote ssh port}

exit 0

# lsusb
Bus 001 Device 005: ID 12d1:14dc Huawei Technologies Co., Ltd.

# cat /etc/udev/rules.d/40-E303Switch.rules  
# Huawei E303 Fallback-Mode Modeswitch

ATTRS{idVendor}==»12d1″, ATTRS{idProduct}==»1f01″, RUN+=»/bin/E303Modeswitch.sh»

# cat /bin/E303Modeswitch.sh
#!/bin/sh

sudo usb_modeswitch -v 0x12d1 -p 0x1f01 -V 0x12d1 -P 0x14db -M «55534243123456780000000000000a11062000000000000100000000000000»

# chmod a+x /bin/E303Modeswitch.sh

После копипаста необходимо поправить кавычки!

Raspberry Pi static IP

Posted: 22nd Март 2016 by shmyak in Пингвин

cat /etc/network/interfaces

auto eth0
allow-hotplug eth0
iface eth0 inet manual

 

cat /etc/dhcpcd.conf

interface eth0
static ip_address=192.168.1.10/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

eltex mes-2124 QinQ

Posted: 2nd Декабрь 2015 by shmyak in Пингвин

gigabitethernet 1/0/2 — gigabitethernet 1/0/3 Jumper

 

console#sh running-config
no spanning-tree
!
vlan database
vlan 555,969
exit
!
interface gigabitethernet 1/0/1
switchport mode trunk
switchport trunk allowed vlan add 969
description uplink
switchport forbidden default-vlan
exit
!
interface gigabitethernet 1/0/2
switchport mode customer
switchport customer vlan 969
switchport forbidden default-vlan
exit
!
interface gigabitethernet 1/0/3
switchport mode trunk
switchport trunk allowed vlan add 555
switchport forbidden default-vlan
exit
!
interface gigabitethernet 1/0/4
switchport access vlan 555
description downlink
switchport forbidden default-vlan
exit
!
interface vlan 555
name test
exit
!
interface vlan 969
name qinq
exit
!

Android MTP for Fedora Linux

Posted: 5th Ноябрь 2015 by shmyak in Пингвин

All that is required for Thunar to see the phone’s internal storage is :

dnf install gvfs-mtp

and reboot — this step seemed mandatory (probably just re-logging into X would work, but the machine wanted an update anyway).

Posted: 29th Октябрь 2015 by shmyak in Юмор

f5a6c22a-31fb-4e8c-8d60-3f55fec8a431-medium

Arduino. Капельный полив растений.

Posted: 13th Август 2015 by shmyak in arduino

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);

#define relay 13
#define MAX_FLOWTIME 180 // seconds
#define MIN_FLOWTIME 30 // seconds
#define MAX 1022
#define MIN 5
int volumePin = A0;
long duration;
long interval = 3000;
long oldDuration;

void setup()
{
Serial.begin(9600);
pinMode(relay, OUTPUT);
lcd.init();
lcd.backlight();
}

void water() {
static bool state;
static unsigned long time;
if((millis() — time) > (state ? duration : interval))
{
state = !state;
digitalWrite(relay, state);
time = millis();
Serial.println(duration);

}
}

void lcd_print() {
lcd.setCursor(0,0);
lcd.print(duration / 1000);
}

void loop() {
duration = map(analogRead(volumePin), MIN, MAX, MIN_FLOWTIME, MAX_FLOWTIME) * 1000;
if (duration != oldDuration){
lcd.clear();
}

lcd_print();
water();
oldDuration = duration;
}

Таймер для ардуины

Posted: 13th Август 2015 by shmyak in arduino

#define relay 13
long duration = 1000;
long interval = 3000;
void setup()
{
Serial.begin(9600);
pinMode(relay, OUTPUT);
}

void loop()
{
static bool state;
static unsigned long time;
if((millis() — time) > (state ? duration : interval))
{
state = !state;
digitalWrite(relay, state);
time = millis();
}
}

xfce system hotkeys

Posted: 29th Июль 2015 by shmyak in Пингвин

~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

konsole hotkeys

~/.kde/share/config/konsolerc
~/.kde/share/apps/konsole
~/.kde/share/apps/konsole/konsoleui.rc
~/.kde/share/apps/konsole/konsole
~/.config/konsolerc

Keyboard volume buttons

xfce4-volumedAUR maps volume keys to xfce-mixer, and displays notifications through xfce4-notifyd. When using PulseAudio, use xfce4-volumed-pulseAUR instead. See also #Xfce4-mixer and pulseaudio.

If you are using PulseAudio and do not wish to use Xfce4 mixer, you could use xfce4-pulseaudio-pluginAUR instead. This package provides a mixer applet for the panel and has support for the keyboard volume keys.

For non desktop environment specific alternatives, see List of applications#Volume managers.